###Clear R--------------------
rm(list=ls())

###Function to recode variables to range from lowest (0) to highest (1) observation---------------------
zero1 <- function(x, minx=NA, maxx=NA){
  res <- NA
  if(is.na(minx)) res <- (x - min(x,na.rm=T))/(max(x,na.rm=T) -min(x,na.rm=T))
  if(!is.na(minx)) res <- (x - minx)/(maxx -minx)
  res
}

####function to install packages if they don't exist----------------
ipak <- function(pkg){
  new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
  if (length(new.pkg)) 
    install.packages(new.pkg, dependencies = TRUE)
  sapply(pkg, require, character.only = TRUE)
}
# usage
packages <- c("psych", "ggplot2", "interplot", "MASS", "foreign",  "car", "stringr", "stargazer", "xtable", "moments", "dplyr")
ipak(packages)

#load data
load("Study3_data.Rdata")

### Appendix C.1: Replication of Food Irradiation Experiment-----------------------

#Two-way
results_food<-list()
summary(results_food[[1]]<-lm(zero1(DV_irradiation)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(results_food[[2]]<-lm(zero1(DV_irradiation)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(NFC)*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)) #NFC
summary(results_food[[3]]<-lm(zero1(DV_irradiation)~InParty_food+OutParty_food + zero1(PSIDstrength)+cogresources+InParty_food*cogresources+OutParty_food*cogresources +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + cogresources*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data, CRT_honest==1)) #resources

#Three way
summary(results_food[[4]]<-lm(zero1(DV_irradiation)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_food*zero1(PSIDstrength)*zero1(CRTall)+OutParty_food*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(results_food[[5]]<-lm(zero1(DV_irradiation)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_food*zero1(PSIDstrength)*zero1(NFC)+OutParty_food*zero1(PSIDstrength)*zero1(NFC) + age+female+ non_white +as.factor(edu)+Republican_dummy,data)) #NFC
summary(results_food[[6]]<-lm(zero1(DV_irradiation)~InParty_food+OutParty_food+zero1(PSIDstrength)+cogresources+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*cogresources+OutParty_food*cogresources+zero1(PSIDstrength)*cogresources+InParty_food*zero1(PSIDstrength)*cogresources+OutParty_food*zero1(PSIDstrength)*cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #Cog resources

#replace names 2 way model
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "InParty_food:zero1(CRTall)"] <- "InParty:CRT"
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "OutParty_food:zero1(CRTall)"] <- "OutParty:CRT"
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"

names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "InParty_food:zero1(NFC)"] <- "InParty:CRT"
names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "OutParty_food:zero1(NFC)"] <- "OutParty:CRT"
names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"

names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "cogresources"] <- "CRT"
names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "InParty_food:cogresources"] <- "InParty:CRT"
names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "OutParty_food:cogresources"] <- "OutParty:CRT"
names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"

#replace names 3-way table
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "InParty_food:zero1(CRTall)"] <- "InParty:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "OutParty_food:zero1(CRTall)"] <- "OutParty:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "InParty_food:zero1(PSIDstrength):zero1(CRTall)"] <- "InParty:PIDstrength:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "OutParty_food:zero1(PSIDstrength):zero1(CRTall)"] <- "OutParty:PIDstrength:CRT"

names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "InParty_food:zero1(NFC)"] <- "InParty:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "OutParty_food:zero1(NFC)"] <- "OutParty:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "InParty_food:zero1(PSIDstrength):zero1(NFC)"] <- "InParty:PIDstrength:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "OutParty_food:zero1(PSIDstrength):zero1(NFC)"] <- "OutParty:PIDstrength:CRT"

names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "cogresources"] <- "CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "InParty_food:cogresources"] <- "InParty:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "OutParty_food:cogresources"] <- "OutParty:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "InParty_food:zero1(PSIDstrength):cogresources"] <- "InParty:PIDstrength:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "OutParty_food:zero1(PSIDstrength):cogresources"] <- "OutParty:PIDstrength:CRT"

stargazer(results_food[[1]], results_food[[4]], results_food[[2]], results_food[[5]],results_food[[3]], results_food[[6]], title="Study 3: Food irradiation support, party cues, reflection and social identity strength", align=TRUE, order=c(1,2,3,4,11,12, 13,14,15,16,17,5,6,7,8,9,10), covariate.labels=c("In-party cue", "Out-party cue", "Partisan Identity Strength (PSID)","Cognitive resource", "In-party * PSID", "Out-party * PSID", "In-party * Cognitive", "Out-party * Cognitive", "PSID * Cognitive", "In-party * PSID * Cognitive", "Out-party * PSID * Cognitive", "Age", "Female", "Race: non-white", "Education: Some college", "Education: College", "Party: Republican", "Constant"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "+p<.1; *p<0.05", column.sep.width = "1pt",
          no.space=TRUE,font.size="tiny" , out = "Study3_summary.tex",dep.var.caption = "Policy support",column.labels = c("CRT", "NFC", "Cog resources"), column.separate = c(2, 2, 2), dep.var.labels.include = F,label="tab:stud3_stats", digits=2)


### Create the figure belonging to Appendix C.1

#CRT
m0 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m0)
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m1)
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m2)
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

##NFC plots belonging to Figure 
## NFC at 0 or -1SD
m0 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)-sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)-sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)+sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)+sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'
forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot_nfc$CRT,levels = c("-1 SD","Mean","+1 SD"))

#Cognitive resources
m0 <- lm(zero1(DV_irradiation)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(zero1(DV_irradiation)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(zero1(DV_irradiation)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'
forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
food_replication<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+geom_line(aes(linetype=Cue, color=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effect of Party Cues on Policy Support ")+geom_ribbon(aes(ymin=lb,ymax=ub, fill=Cue),alpha=.4)+geom_hline(yintercept = 0,lty="dashed")+scale_fill_manual(values=c("dark green", "red"))+scale_colour_manual(values=c("black", "black")) + theme(strip.text.y = element_text(angle = 360), legend.position="bottom")
ggsave(food_replication, file="study3_food.pdf",width=8,height=6)



### Appendix C.2: Replication of the Farm Policy Experiment -----------------------

#Two-way
results_farm<-list()
summary(results_farm[[1]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+zero1(CRTall)+InParty_farm*zero1(CRTall)+OutParty_farm*zero1(CRTall) +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,data, CRT_honest==1)) #CRT
summary(results_farm[[2]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+zero1(NFC)+InParty_farm*zero1(NFC)+OutParty_farm*zero1(NFC) +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + zero1(NFC)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,data)) #NFC
summary(results_farm[[3]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+cogresources+InParty_farm*cogresources+OutParty_farm*cogresources +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + cogresources*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy  ,data, CRT_honest==1)) #cog resources

#Three way
summary(results_farm[[4]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+zero1(CRTall)+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*zero1(CRTall)+OutParty_farm*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_farm*zero1(PSIDstrength)*zero1(CRTall)+OutParty_farm*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy  ,data, CRT_honest==1)) #CRT
summary(results_farm[[5]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+zero1(NFC)+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*zero1(NFC)+OutParty_farm*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_farm*zero1(PSIDstrength)*zero1(NFC)+OutParty_farm*zero1(PSIDstrength)*zero1(NFC)+ age+female+ non_white +as.factor(edu)+Republican_dummy  ,data)) #NFC
summary(results_farm[[6]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+cogresources+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*cogresources+OutParty_farm*cogresources+zero1(PSIDstrength)*cogresources+InParty_farm*zero1(PSIDstrength)*cogresources+OutParty_farm*zero1(PSIDstrength)*cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy  ,data, CRT_honest==1)) #cog resources

#replace names 2 way model
names(results_farm[[1]]$coefficients)[names(results_farm[[1]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(results_farm[[1]]$coefficients)[names(results_farm[[1]]$coefficients) == "InParty_farm:zero1(CRTall)"] <- "InParty:CRT"
names(results_farm[[1]]$coefficients)[names(results_farm[[1]]$coefficients) == "OutParty_farm:zero1(CRTall)"] <- "OutParty:CRT"
names(results_farm[[1]]$coefficients)[names(results_farm[[1]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"

names(results_farm[[2]]$coefficients)[names(results_farm[[2]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(results_farm[[2]]$coefficients)[names(results_farm[[2]]$coefficients) == "InParty_farm:zero1(NFC)"] <- "InParty:CRT"
names(results_farm[[2]]$coefficients)[names(results_farm[[2]]$coefficients) == "OutParty_farm:zero1(NFC)"] <- "OutParty:CRT"
names(results_farm[[2]]$coefficients)[names(results_farm[[2]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"

names(results_farm[[3]]$coefficients)[names(results_farm[[3]]$coefficients) == "cogresources"] <- "CRT"
names(results_farm[[3]]$coefficients)[names(results_farm[[3]]$coefficients) == "InParty_farm:cogresources"] <- "InParty:CRT"
names(results_farm[[3]]$coefficients)[names(results_farm[[3]]$coefficients) == "OutParty_farm:cogresources"] <- "OutParty:CRT"
names(results_farm[[3]]$coefficients)[names(results_farm[[3]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"

#replace names 3-way table
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "InParty_farm:zero1(CRTall)"] <- "InParty:CRT"
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "OutParty_farm:zero1(CRTall)"] <- "OutParty:CRT"
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "InParty_farm:zero1(PSIDstrength):zero1(CRTall)"] <- "InParty:PIDstrength:CRT"
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "OutParty_farm:zero1(PSIDstrength):zero1(CRTall)"] <- "OutParty:PIDstrength:CRT"

names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "InParty_farm:zero1(NFC)"] <- "InParty:CRT"
names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "OutParty_farm:zero1(NFC)"] <- "OutParty:CRT"
names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"
names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "InParty_farm:zero1(PSIDstrength):zero1(NFC)"] <- "InParty:PIDstrength:CRT"
names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "OutParty_farm:zero1(PSIDstrength):zero1(NFC)"] <- "OutParty:PIDstrength:CRT"

names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "cogresources"] <- "CRT"
names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "InParty_farm:cogresources"] <- "InParty:CRT"
names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "OutParty_farm:cogresources"] <- "OutParty:CRT"
names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"
names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "InParty_farm:zero1(PSIDstrength):cogresources"] <- "InParty:PIDstrength:CRT"
names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "OutParty_farm:zero1(PSIDstrength):cogresources"] <- "OutParty:PIDstrength:CRT"

stargazer(results_farm[[1]], results_farm[[4]], results_farm[[2]], results_farm[[5]],results_farm[[3]], results_farm[[6]], title="Replication Farm Policy study: party cues, reflection and social identity strength", align=TRUE, order=c(1,2,3,4,11,12, 13,14,15,16,17,5,6,7,8,9,10), covariate.labels=c("In-party cue", "Out-party cue", "Partisan Identity Strength (PSID)","Cognitive resource", "In-party * PSID", "Out-party * PSID", "In-party * Cognitive", "Out-party * Cognitive", "PSID * Cognitive", "In-party * PSID * Cognitive", "Out-party * PSID * Cognitive", "Age", "Female", "Race: non-white", "Education: Some college", "Education: College", "Party: Republican", "Constant"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "+p<.1; *p<0.05", column.sep.width = "1pt",
          no.space=TRUE,font.size="tiny" , out = "Study3_summary_farm.tex",dep.var.caption = "Policy support",column.labels = c("CRT", "NFC", "Cog resoucres"), column.separate = c(2, 2, 2), dep.var.labels.include = F,label="tab:stud4_farm", digits=2)


####Figure for Farm Policy 
## CRT at 0 or -1SD
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'
summary(m0)
## CRT at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'
summary(m2)
forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

##NfC plots belonging to Figure for Farm Policy
## NFC at 0 or -1SD
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## NFC at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## NFC at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

## Cog resources at -1
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
farm_replication<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+geom_line(aes(linetype=Cue, color=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effect of Party Cues on Policy Support ")+geom_ribbon(aes(ymin=lb,ymax=ub, fill=Cue),alpha=.4)+geom_hline(yintercept = 0,lty="dashed")+scale_fill_manual(values=c("dark green", "red"))+scale_colour_manual(values=c("black", "black")) + theme(strip.text.y = element_text(angle = 360), legend.position="bottom") 
ggsave(farm_replication, file="study3_farm.pdf",width=8,height=6)

### Appendix C.3: Inspection of the Mechanism: Reading time in Food Irradation Experiment -----------------------

data$partycues_food<-1
data$partycues_food[data$InParty_food==1]=2
data$partycues_food[data$OutParty_food==1]=3

food<-as.data.frame(data %>%
                      group_by(partycues_food) %>%
                      dplyr::summarize(Mean = mean(Food_time_Page_Submit, na.rm=TRUE), SD = sd(Food_time_Page_Submit, na.rm=TRUE), Min = min(Food_time_Page_Submit, na.rm=TRUE), Max = max(Food_time_Page_Submit, na.rm=TRUE)))
food$Cue<-c("No cues", "In-party cue", "Out-party cue")
food<-food[,-c(1)]
food<-food[,c(5, 1,2,3,4)]
food<-xtable(caption = "Study 3 Food Irradiation Experiment: Reading Time", label = "tab:reading_food", food)
print(food, type="latex", file="Study3_Food_read.tex", caption.placement="top")

#Main effects
food_read<-list()
summary(food_read[[1]]<-lm(log1p(Food_time_Page_Submit)~InParty_food + OutParty_food + zero1(PSIDstrength) + zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) # Strong identifiers read less. High CRT read more
summary(food_read[[2]]<-lm(log1p(Food_time_Page_Submit)~InParty_food + OutParty_food + zero1(PSIDstrength) + zero1(NFC)+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)) #NFC Strong identifiers read less. High NfC read more
summary(food_read[[3]]<-lm(log1p(Food_time_Page_Submit)~InParty_food + OutParty_food + zero1(PSIDstrength) + cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #Strong identifiers read less. High Resources read more

summary(food_read[[4]]<-lm(log1p(Food_time_Page_Submit)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(food_read[[5]]<-lm(log1p(Food_time_Page_Submit)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(NFC)*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)) #NFC
summary(food_read[[6]]<-lm(log1p(Food_time_Page_Submit)~InParty_food+OutParty_food + zero1(PSIDstrength)+cogresources+InParty_food*cogresources+OutParty_food*cogresources +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + cogresources*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #resources

#Three way
summary(food_read[[7]]<-lm(log1p(Food_time_Page_Submit)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_food*zero1(PSIDstrength)*zero1(CRTall)+OutParty_food*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(food_read[[8]]<-lm(log1p(Food_time_Page_Submit)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_food*zero1(PSIDstrength)*zero1(NFC)+OutParty_food*zero1(PSIDstrength)*zero1(NFC) + age+female+ non_white +as.factor(edu)+Republican_dummy,data)) #NFC
summary(food_read[[9]]<-lm(log1p(Food_time_Page_Submit)~InParty_food+OutParty_food+zero1(PSIDstrength)+cogresources+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*cogresources+OutParty_food*cogresources+zero1(PSIDstrength)*cogresources+InParty_food*zero1(PSIDstrength)*cogresources+OutParty_food*zero1(PSIDstrength)*cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #Cog resources

#replace names 1 way model
names(food_read[[1]]$coefficients)[names(food_read[[1]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(food_read[[2]]$coefficients)[names(food_read[[2]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(food_read[[3]]$coefficients)[names(food_read[[3]]$coefficients) == "cogresources"] <- "CRT"

#replace names 2-way table
names(food_read[[4]]$coefficients)[names(food_read[[4]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(food_read[[4]]$coefficients)[names(food_read[[4]]$coefficients) == "InParty_food:zero1(CRTall)"] <- "InParty:CRT"
names(food_read[[4]]$coefficients)[names(food_read[[4]]$coefficients) == "OutParty_food:zero1(CRTall)"] <- "OutParty:CRT"
names(food_read[[4]]$coefficients)[names(food_read[[4]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"

names(food_read[[5]]$coefficients)[names(food_read[[5]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(food_read[[5]]$coefficients)[names(food_read[[5]]$coefficients) == "InParty_food:zero1(NFC)"] <- "InParty:CRT"
names(food_read[[5]]$coefficients)[names(food_read[[5]]$coefficients) == "OutParty_food:zero1(NFC)"] <- "OutParty:CRT"
names(food_read[[5]]$coefficients)[names(food_read[[5]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"

names(food_read[[6]]$coefficients)[names(food_read[[6]]$coefficients) == "cogresources"] <- "CRT"
names(food_read[[6]]$coefficients)[names(food_read[[6]]$coefficients) == "InParty_food:cogresources"] <- "InParty:CRT"
names(food_read[[6]]$coefficients)[names(food_read[[6]]$coefficients) == "OutParty_food:cogresources"] <- "OutParty:CRT"
names(food_read[[6]]$coefficients)[names(food_read[[6]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"

#replace names 3-way table
names(food_read[[7]]$coefficients)[names(food_read[[7]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(food_read[[7]]$coefficients)[names(food_read[[7]]$coefficients) == "InParty_food:zero1(CRTall)"] <- "InParty:CRT"
names(food_read[[7]]$coefficients)[names(food_read[[7]]$coefficients) == "OutParty_food:zero1(CRTall)"] <- "OutParty:CRT"
names(food_read[[7]]$coefficients)[names(food_read[[7]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"
names(food_read[[7]]$coefficients)[names(food_read[[7]]$coefficients) == "InParty_food:zero1(PSIDstrength):zero1(CRTall)"] <- "InParty:PIDstrength:CRT"
names(food_read[[7]]$coefficients)[names(food_read[[7]]$coefficients) == "OutParty_food:zero1(PSIDstrength):zero1(CRTall)"] <- "OutParty:PIDstrength:CRT"

names(food_read[[8]]$coefficients)[names(food_read[[8]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(food_read[[8]]$coefficients)[names(food_read[[8]]$coefficients) == "InParty_food:zero1(NFC)"] <- "InParty:CRT"
names(food_read[[8]]$coefficients)[names(food_read[[8]]$coefficients) == "OutParty_food:zero1(NFC)"] <- "OutParty:CRT"
names(food_read[[8]]$coefficients)[names(food_read[[8]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"
names(food_read[[8]]$coefficients)[names(food_read[[8]]$coefficients) == "InParty_food:zero1(PSIDstrength):zero1(NFC)"] <- "InParty:PIDstrength:CRT"
names(food_read[[8]]$coefficients)[names(food_read[[8]]$coefficients) == "OutParty_food:zero1(PSIDstrength):zero1(NFC)"] <- "OutParty:PIDstrength:CRT"

names(food_read[[9]]$coefficients)[names(food_read[[9]]$coefficients) == "cogresources"] <- "CRT"
names(food_read[[9]]$coefficients)[names(food_read[[9]]$coefficients) == "InParty_food:cogresources"] <- "InParty:CRT"
names(food_read[[9]]$coefficients)[names(food_read[[9]]$coefficients) == "OutParty_food:cogresources"] <- "OutParty:CRT"
names(food_read[[9]]$coefficients)[names(food_read[[9]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"
names(food_read[[9]]$coefficients)[names(food_read[[9]]$coefficients) == "InParty_food:zero1(PSIDstrength):cogresources"] <- "InParty:PIDstrength:CRT"
names(food_read[[9]]$coefficients)[names(food_read[[9]]$coefficients) == "OutParty_food:zero1(PSIDstrength):cogresources"] <- "OutParty:PIDstrength:CRT"

stargazer(food_read[[1]], food_read[[4]], food_read[[7]], food_read[[2]],food_read[[5]], food_read[[8]], food_read[[3]], food_read[[5]],food_read[[9]], title="Study 3: Reading Time in the Food Irradiation Experiment: Party Cues, Reflection and Partisan Social Identity Strength", align=TRUE, order=c(1,2,3,4,11,12, 13,14,15,16,17,5,6,7,8,9,10), covariate.labels=c("In-party cue", "Out-party cue", "PSID","Cognitive resource", "In-party * PSID", "Out-party * PSID", "In-party * Cognitive", "Out-party * Cognitive", "PSID * Cognitive", "In-party * PSID * Cognitive", "Out-party * PSID * Cognitive", "Age", "Female", "Race: non-white", "Education: Some college", "Education: College", "Party: Republican", "Constant"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "+p<.1; *p<0.05", column.sep.width = "1pt",
          no.space=TRUE,font.size="tiny" , out = "Study3_read.tex",dep.var.caption = "Reading time",column.labels = c("CRT", "NFC", "Cognitive resources"), column.separate = c(3, 3,3), dep.var.labels.include = F,label="tab:stud4_read", digits=2)

##make Figure 

## CRT at 0 or -1SD
m0 <- lm(log1p(Food_time_Page_Submit)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(log1p(Food_time_Page_Submit)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(log1p(Food_time_Page_Submit)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

##NfC plots belonging to Figure for Farm Policy
## NFC at 0 or -1SD
m0 <- lm(log1p(Food_time_Page_Submit)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## NFC at mean
m1 <- lm(log1p(Food_time_Page_Submit)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## NFC at +1
m2 <- lm(log1p(Food_time_Page_Submit)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

## Cog resources at -1
m0 <- lm(log1p(Food_time_Page_Submit)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(log1p(Food_time_Page_Submit)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(log1p(Food_time_Page_Submit)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
food_read<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+geom_line(aes(linetype=Cue, color=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effect of Party Cues on Reading Time (log transformed)")+geom_ribbon(aes(ymin=lb,ymax=ub, fill=Cue),alpha=.4)+geom_hline(yintercept = 0,lty="dashed")+scale_fill_manual(values=c("dark green", "red"))+scale_colour_manual(values=c("black", "black")) + theme(strip.text.y = element_text(angle = 360), legend.position="bottom") 
ggsave(food_read, file="study3_food_read.pdf",width=8,height=6)

### Appendix C.3: Inspection of the Mechanism: Reading time in Farm Subsidy Experiment -----------------------

data$partycues_farm<-1
data$partycues_farm[data$InParty_farm==1]=2
data$partycues_farm[data$OutParty_farm==1]=3

farm<-as.data.frame(data %>%
                      group_by(partycues_farm) %>%
                      dplyr::summarize(Mean = mean(Farm_time_Page_Submit, na.rm=TRUE), SD = sd(Farm_time_Page_Submit, na.rm=TRUE), Min = min(Farm_time_Page_Submit, na.rm=TRUE), Max = max(Farm_time_Page_Submit, na.rm=TRUE)))
farm$Cue<-c("No cues", "In-party cue", "Out-party cue")
farm<-farm[,-c(1)]
farm<-farm[,c(5, 1,2,3,4)]
farm<-xtable(caption = "Study 3 Farm Subsidy Experiment: Reading Time", label = "tab:reading_farm", farm)
print(farm, type="latex", file="Study3_Farm_read.tex", caption.placement="top")


#main effects
farm_read<-list()
summary(farm_read[[1]]<-lm(log1p(Farm_time_Page_Submit)~InParty_farm + OutParty_farm + zero1(PSIDstrength) + zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #CRT
summary(farm_read[[2]]<-lm(log1p(Farm_time_Page_Submit)~InParty_farm + OutParty_farm + zero1(PSIDstrength) + zero1(NFC)+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data))) #NFC
summary(farm_read[[3]]<-lm(log1p(Farm_time_Page_Submit)~InParty_farm + OutParty_farm + zero1(PSIDstrength) +cogresources + age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #NFC

#Twoway
summary(farm_read[[4]]<-lm(log1p(Farm_time_Page_Submit)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+zero1(CRTall)+InParty_farm*zero1(CRTall)+OutParty_farm*zero1(CRTall) +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,data, CRT_honest==1)) #CRT
summary(farm_read[[5]]<-lm(log1p(Farm_time_Page_Submit)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+zero1(NFC)+InParty_farm*zero1(NFC)+OutParty_farm*zero1(NFC) +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + zero1(NFC)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,data)) #NFC
summary(farm_read[[6]]<-lm(log1p(Farm_time_Page_Submit)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+cogresources+InParty_farm*cogresources+OutParty_farm*cogresources +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + cogresources*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy  ,data, CRT_honest==1)) #cog resources

#Three way
summary(farm_read[[7]]<-lm(log1p(Farm_time_Page_Submit)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+zero1(CRTall)+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*zero1(CRTall)+OutParty_farm*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_farm*zero1(PSIDstrength)*zero1(CRTall)+OutParty_farm*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(farm_read[[8]]<-lm(log1p(Farm_time_Page_Submit)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+zero1(NFC)+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*zero1(NFC)+OutParty_farm*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_farm*zero1(PSIDstrength)*zero1(NFC)+OutParty_farm*zero1(PSIDstrength)*zero1(NFC) + age+female+ non_white +as.factor(edu)+Republican_dummy,data)) #NFC
summary(farm_read[[9]]<-lm(log1p(Farm_time_Page_Submit)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+cogresources+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*cogresources+OutParty_farm*cogresources+zero1(PSIDstrength)*cogresources+InParty_farm*zero1(PSIDstrength)*cogresources+OutParty_farm*zero1(PSIDstrength)*cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #Cog resources

#replace names 1 way model
names(farm_read[[1]]$coefficients)[names(farm_read[[1]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(farm_read[[2]]$coefficients)[names(farm_read[[2]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(farm_read[[3]]$coefficients)[names(farm_read[[3]]$coefficients) == "cogresources"] <- "CRT"

#replace names 2 way model
names(farm_read[[4]]$coefficients)[names(farm_read[[4]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(farm_read[[4]]$coefficients)[names(farm_read[[4]]$coefficients) == "InParty_farm:zero1(CRTall)"] <- "InParty:CRT"
names(farm_read[[4]]$coefficients)[names(farm_read[[4]]$coefficients) == "OutParty_farm:zero1(CRTall)"] <- "OutParty:CRT"
names(farm_read[[4]]$coefficients)[names(farm_read[[4]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"

names(farm_read[[5]]$coefficients)[names(farm_read[[5]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(farm_read[[5]]$coefficients)[names(farm_read[[5]]$coefficients) == "InParty_farm:zero1(NFC)"] <- "InParty:CRT"
names(farm_read[[5]]$coefficients)[names(farm_read[[5]]$coefficients) == "OutParty_farm:zero1(NFC)"] <- "OutParty:CRT"
names(farm_read[[5]]$coefficients)[names(farm_read[[5]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"

names(farm_read[[6]]$coefficients)[names(farm_read[[6]]$coefficients) == "cogresources"] <- "CRT"
names(farm_read[[6]]$coefficients)[names(farm_read[[6]]$coefficients) == "InParty_farm:cogresources"] <- "InParty:CRT"
names(farm_read[[6]]$coefficients)[names(farm_read[[6]]$coefficients) == "OutParty_farm:cogresources"] <- "OutParty:CRT"
names(farm_read[[6]]$coefficients)[names(farm_read[[6]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"

#replace names 3-way table
names(farm_read[[7]]$coefficients)[names(farm_read[[7]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(farm_read[[7]]$coefficients)[names(farm_read[[7]]$coefficients) == "InParty_farm:zero1(CRTall)"] <- "InParty:CRT"
names(farm_read[[7]]$coefficients)[names(farm_read[[7]]$coefficients) == "OutParty_farm:zero1(CRTall)"] <- "OutParty:CRT"
names(farm_read[[7]]$coefficients)[names(farm_read[[7]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"
names(farm_read[[7]]$coefficients)[names(farm_read[[7]]$coefficients) == "InParty_farm:zero1(PSIDstrength):zero1(CRTall)"] <- "InParty:PIDstrength:CRT"
names(farm_read[[7]]$coefficients)[names(farm_read[[7]]$coefficients) == "OutParty_farm:zero1(PSIDstrength):zero1(CRTall)"] <- "OutParty:PIDstrength:CRT"

names(farm_read[[8]]$coefficients)[names(farm_read[[8]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(farm_read[[8]]$coefficients)[names(farm_read[[8]]$coefficients) == "InParty_farm:zero1(NFC)"] <- "InParty:CRT"
names(farm_read[[8]]$coefficients)[names(farm_read[[8]]$coefficients) == "OutParty_farm:zero1(NFC)"] <- "OutParty:CRT"
names(farm_read[[8]]$coefficients)[names(farm_read[[8]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"
names(farm_read[[8]]$coefficients)[names(farm_read[[8]]$coefficients) == "InParty_farm:zero1(PSIDstrength):zero1(NFC)"] <- "InParty:PIDstrength:CRT"
names(farm_read[[8]]$coefficients)[names(farm_read[[8]]$coefficients) == "OutParty_farm:zero1(PSIDstrength):zero1(NFC)"] <- "OutParty:PIDstrength:CRT"

names(farm_read[[9]]$coefficients)[names(farm_read[[9]]$coefficients) == "cogresources"] <- "CRT"
names(farm_read[[9]]$coefficients)[names(farm_read[[9]]$coefficients) == "InParty_farm:cogresources"] <- "InParty:CRT"
names(farm_read[[9]]$coefficients)[names(farm_read[[9]]$coefficients) == "OutParty_farm:cogresources"] <- "OutParty:CRT"
names(farm_read[[9]]$coefficients)[names(farm_read[[9]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"
names(farm_read[[9]]$coefficients)[names(farm_read[[9]]$coefficients) == "InParty_farm:zero1(PSIDstrength):cogresources"] <- "InParty:PIDstrength:CRT"
names(farm_read[[9]]$coefficients)[names(farm_read[[9]]$coefficients) == "OutParty_farm:zero1(PSIDstrength):cogresources"] <- "OutParty:PIDstrength:CRT"

stargazer(farm_read[[1]], farm_read[[4]], farm_read[[7]], farm_read[[2]],farm_read[[5]], farm_read[[8]], farm_read[[3]],farm_read[[6]], farm_read[[9]], title="Study 3: Reading time in the Farm Subsidy Experiment: Party Cues, Reflection and Partisan Social Identity Strength", align=TRUE, order=c(1,2,3,4,11,12, 13,14,15,16,17,5,6,7,8,9,10), covariate.labels=c("In-party cue", "Out-party cue", "PSID","Cognitive resource", "In-party * PSID", "Out-party * PSID", "In-party * Cognitive", "Out-party * Cognitive", "PSID * Cognitive", "In-party * PSID * Cognitive", "Out-party * PSID * Cognitive", "Age", "Female", "Race: non-white", "Education: Some college", "Education: College", "Party: Republican", "Constant"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "+p<.1; *p<0.05", column.sep.width = "1pt",
          no.space=TRUE,font.size="tiny" , out = "Study3_read_farm.tex",dep.var.caption = "Reading time",column.labels = c("CRT", "NFC", "Cognitive resources"), column.separate = c(3, 3, 3), dep.var.labels.include = F,label="tab:stud4_read_farm", digits=2)

m0 <- lm(log1p(Farm_time_Page_Submit)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(log1p(Farm_time_Page_Submit)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(log1p(Farm_time_Page_Submit)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

##NfC plots belonging to Figure for Farm Policy
## NFC at 0 or -1SD
m0 <- lm(log1p(Farm_time_Page_Submit)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## NFC at mean
m1 <- lm(log1p(Farm_time_Page_Submit)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## NFC at +1
m2 <- lm(log1p(Farm_time_Page_Submit)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

## Cog resources at -1
m0 <- lm(log1p(Farm_time_Page_Submit)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(log1p(Farm_time_Page_Submit)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(log1p(Farm_time_Page_Submit)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
farm_read<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+geom_line(aes(linetype=Cue, color=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effect of Party Cues on Reading Time (log transfromed) ")+geom_ribbon(aes(ymin=lb,ymax=ub, fill=Cue),alpha=.4)+geom_hline(yintercept = 0,lty="dashed")+scale_fill_manual(values=c("dark green", "red"))+scale_colour_manual(values=c("black", "black")) + theme(strip.text.y = element_text(angle = 360), legend.position="bottom") 
ggsave(farm_read, file="study3_farm_read.pdf",width=8,height=6)


### Appendix C.4: Inspection of the Mechanism: Thoughts ---------------------
summary(data$words)
sd(data$words)
Food_words<-list()
summary(Food_words[[1]]<-lm(log1p(words)~InParty_food + OutParty_food + zero1(PSIDstrength) + zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1)))
summary(Food_words[[2]]<-lm(log1p(words)~InParty_food + OutParty_food + zero1(PSIDstrength) + zero1(NFC)+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)) 
summary(Food_words[[3]]<-lm(log1p(words)~InParty_food + OutParty_food + zero1(PSIDstrength) + cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) 
#twoway
summary(Food_words[[4]]<-lm(log1p(words)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(Food_words[[5]]<-lm(log1p(words)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(NFC)*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)) #NFC
summary(Food_words[[6]]<-lm(log1p(words)~InParty_food+OutParty_food + zero1(PSIDstrength)+cogresources+InParty_food*cogresources+OutParty_food*cogresources +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + cogresources*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #resources

#Three way
summary(Food_words[[7]]<-lm(log1p(words)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_food*zero1(PSIDstrength)*zero1(CRTall)+OutParty_food*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(Food_words[[8]]<-lm(log1p(words)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_food*zero1(PSIDstrength)*zero1(NFC)+OutParty_food*zero1(PSIDstrength)*zero1(NFC) + age+female+ non_white +as.factor(edu)+Republican_dummy,data)) #NFC
summary(Food_words[[9]]<-lm(log1p(words)~InParty_food+OutParty_food+zero1(PSIDstrength)+cogresources+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*cogresources+OutParty_food*cogresources+zero1(PSIDstrength)*cogresources+InParty_food*zero1(PSIDstrength)*cogresources+OutParty_food*zero1(PSIDstrength)*cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #Cog resources

#replace names 1 way model
names(Food_words[[1]]$coefficients)[names(Food_words[[1]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(Food_words[[2]]$coefficients)[names(Food_words[[2]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(Food_words[[3]]$coefficients)[names(Food_words[[3]]$coefficients) == "cogresources"] <- "CRT"

#replace names 2-way table
names(Food_words[[4]]$coefficients)[names(Food_words[[4]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(Food_words[[4]]$coefficients)[names(Food_words[[4]]$coefficients) == "InParty_food:zero1(CRTall)"] <- "InParty:CRT"
names(Food_words[[4]]$coefficients)[names(Food_words[[4]]$coefficients) == "OutParty_food:zero1(CRTall)"] <- "OutParty:CRT"
names(Food_words[[4]]$coefficients)[names(Food_words[[4]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"

names(Food_words[[5]]$coefficients)[names(Food_words[[5]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(Food_words[[5]]$coefficients)[names(Food_words[[5]]$coefficients) == "InParty_food:zero1(NFC)"] <- "InParty:CRT"
names(Food_words[[5]]$coefficients)[names(Food_words[[5]]$coefficients) == "OutParty_food:zero1(NFC)"] <- "OutParty:CRT"
names(Food_words[[5]]$coefficients)[names(Food_words[[5]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"

names(Food_words[[6]]$coefficients)[names(Food_words[[6]]$coefficients) == "cogresources"] <- "CRT"
names(Food_words[[6]]$coefficients)[names(Food_words[[6]]$coefficients) == "InParty_food:cogresources"] <- "InParty:CRT"
names(Food_words[[6]]$coefficients)[names(Food_words[[6]]$coefficients) == "OutParty_food:cogresources"] <- "OutParty:CRT"
names(Food_words[[6]]$coefficients)[names(Food_words[[6]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"

#replace names 3-way table
names(Food_words[[7]]$coefficients)[names(Food_words[[7]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(Food_words[[7]]$coefficients)[names(Food_words[[7]]$coefficients) == "InParty_food:zero1(CRTall)"] <- "InParty:CRT"
names(Food_words[[7]]$coefficients)[names(Food_words[[7]]$coefficients) == "OutParty_food:zero1(CRTall)"] <- "OutParty:CRT"
names(Food_words[[7]]$coefficients)[names(Food_words[[7]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"
names(Food_words[[7]]$coefficients)[names(Food_words[[7]]$coefficients) == "InParty_food:zero1(PSIDstrength):zero1(CRTall)"] <- "InParty:PIDstrength:CRT"
names(Food_words[[7]]$coefficients)[names(Food_words[[7]]$coefficients) == "OutParty_food:zero1(PSIDstrength):zero1(CRTall)"] <- "OutParty:PIDstrength:CRT"

names(Food_words[[8]]$coefficients)[names(Food_words[[8]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(Food_words[[8]]$coefficients)[names(Food_words[[8]]$coefficients) == "InParty_food:zero1(NFC)"] <- "InParty:CRT"
names(Food_words[[8]]$coefficients)[names(Food_words[[8]]$coefficients) == "OutParty_food:zero1(NFC)"] <- "OutParty:CRT"
names(Food_words[[8]]$coefficients)[names(Food_words[[8]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"
names(Food_words[[8]]$coefficients)[names(Food_words[[8]]$coefficients) == "InParty_food:zero1(PSIDstrength):zero1(NFC)"] <- "InParty:PIDstrength:CRT"
names(Food_words[[8]]$coefficients)[names(Food_words[[8]]$coefficients) == "OutParty_food:zero1(PSIDstrength):zero1(NFC)"] <- "OutParty:PIDstrength:CRT"

names(Food_words[[9]]$coefficients)[names(Food_words[[9]]$coefficients) == "cogresources"] <- "CRT"
names(Food_words[[9]]$coefficients)[names(Food_words[[9]]$coefficients) == "InParty_food:cogresources"] <- "InParty:CRT"
names(Food_words[[9]]$coefficients)[names(Food_words[[9]]$coefficients) == "OutParty_food:cogresources"] <- "OutParty:CRT"
names(Food_words[[9]]$coefficients)[names(Food_words[[9]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"
names(Food_words[[9]]$coefficients)[names(Food_words[[9]]$coefficients) == "InParty_food:zero1(PSIDstrength):cogresources"] <- "InParty:PIDstrength:CRT"
names(Food_words[[9]]$coefficients)[names(Food_words[[9]]$coefficients) == "OutParty_food:zero1(PSIDstrength):cogresources"] <- "OutParty:PIDstrength:CRT"

stargazer(Food_words[[1]], Food_words[[4]], Food_words[[7]], Food_words[[2]],Food_words[[5]], Food_words[[8]], Food_words[[3]],Food_words[[6]], Food_words[[9]], title="Study 3: Words Formulated in the Food Irradiation Experiment: Party Cues, Reflection and Partisan Social Identity Strength", align=TRUE, order=c(1,2,3,4,11,12, 13,14,15,16,17,5,6,7,8,9,10), covariate.labels=c("In-party cue", "Out-party cue", "PSID","Cognitive resource", "In-party * PSID", "Out-party * PSID", "In-party * Cog", "Out-party * Cog", "PSID * Cog", "In-party * PSID * Cog", "Out-party * PSID * Cog", "Age", "Female", "Race: non-white", "Education: Some college", "Education: College", "Party: Republican", "Constant"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "+p<.1; *p<0.05", column.sep.width = "0.5pt",
          no.space=TRUE,font.size="tiny" , out = "Study3_words.tex",dep.var.caption = "Thoughts (number of words)",column.labels = c("CRT", "NFC", "Cognitive resources"), column.separate = c(3, 3,3), dep.var.labels.include = F,label="tab:stud4_words", digits=2)


## CRT at 0 or -1SD
m0 <- lm(log1p(words)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'
summary(m0)
## CRT at mean
m1 <- lm(log1p(words)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(log1p(words)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

##NfC plots belonging to Figure for Farm Policy
## NFC at 0 or -1SD
m0 <- lm(log1p(words)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## NFC at mean
m1 <- lm(log1p(words)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## NFC at +1
m2 <- lm(log1p(words)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

## Cog resources at -1
m0 <- lm(log1p(Food_time_Page_Submit)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(log1p(words)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(log1p(words)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
food_words<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+geom_line(aes(linetype=Cue, color=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effect of Party Cues on Thoughts (words) ")+geom_ribbon(aes(ymin=lb,ymax=ub, fill=Cue),alpha=.4)+geom_hline(yintercept = 0,lty="dashed")+scale_fill_manual(values=c("dark green", "red"))+scale_colour_manual(values=c("black", "black")) + theme(strip.text.y = element_text(angle = 360), legend.position="bottom") 
ggsave(food_words, file="study3_food_words.pdf",width=8,height=6)

### Appendix C.5: Inspection of the Mechanism: Quiz results in Food Irradiation Experiment---------------------

summary(data$Quiz_correct)
sd(data$Quiz_correct, na.rm=T)

#Main effects
food_quiz<-list()
summary(food_quiz[[1]]<-lm(zero1(Quiz_correct)~InParty_food + OutParty_food + zero1(PSIDstrength) + zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) # Strong identifiers read less. High CRT read more
summary(food_quiz[[2]]<-lm(zero1(Quiz_correct)~InParty_food + OutParty_food + zero1(PSIDstrength) + zero1(NFC)+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)) #NFC Strong identifiers read less. High NfC read more
summary(food_quiz[[3]]<-lm(zero1(Quiz_correct)~InParty_food + OutParty_food + zero1(PSIDstrength) + cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #Strong identifiers read less. High Resources read more

#twoway
summary(food_quiz[[4]]<-lm(zero1(Quiz_correct)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(food_quiz[[5]]<-lm(zero1(Quiz_correct)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(NFC)*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)) #NFC
summary(food_quiz[[6]]<-lm(zero1(Quiz_correct)~InParty_food+OutParty_food + zero1(PSIDstrength)+cogresources+InParty_food*cogresources+OutParty_food*cogresources +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + cogresources*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #resources

#Three way
summary(food_quiz[[7]]<-lm(zero1(Quiz_correct)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_food*zero1(PSIDstrength)*zero1(CRTall)+OutParty_food*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(food_quiz[[8]]<-lm(zero1(Quiz_correct)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_food*zero1(PSIDstrength)*zero1(NFC)+OutParty_food*zero1(PSIDstrength)*zero1(NFC) + age+female+ non_white +as.factor(edu)+Republican_dummy,data)) #NFC
summary(food_quiz[[9]]<-lm(zero1(Quiz_correct)~InParty_food+OutParty_food+zero1(PSIDstrength)+cogresources+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*cogresources+OutParty_food*cogresources+zero1(PSIDstrength)*cogresources+InParty_food*zero1(PSIDstrength)*cogresources+OutParty_food*zero1(PSIDstrength)*cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #Cog resources

#replace names 2 way model
names(food_quiz[[1]]$coefficients)[names(food_quiz[[1]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(food_quiz[[2]]$coefficients)[names(food_quiz[[2]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(food_quiz[[3]]$coefficients)[names(food_quiz[[3]]$coefficients) == "cogresources"] <- "CRT"

#replace names 3-way table
names(food_quiz[[4]]$coefficients)[names(food_quiz[[4]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(food_quiz[[4]]$coefficients)[names(food_quiz[[4]]$coefficients) == "InParty_food:zero1(CRTall)"] <- "InParty:CRT"
names(food_quiz[[4]]$coefficients)[names(food_quiz[[4]]$coefficients) == "OutParty_food:zero1(CRTall)"] <- "OutParty:CRT"
names(food_quiz[[4]]$coefficients)[names(food_quiz[[4]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"

names(food_quiz[[5]]$coefficients)[names(food_quiz[[5]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(food_quiz[[5]]$coefficients)[names(food_quiz[[5]]$coefficients) == "InParty_food:zero1(NFC)"] <- "InParty:CRT"
names(food_quiz[[5]]$coefficients)[names(food_quiz[[5]]$coefficients) == "OutParty_food:zero1(NFC)"] <- "OutParty:CRT"
names(food_quiz[[5]]$coefficients)[names(food_quiz[[5]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"

names(food_quiz[[6]]$coefficients)[names(food_quiz[[6]]$coefficients) == "cogresources"] <- "CRT"
names(food_quiz[[6]]$coefficients)[names(food_quiz[[6]]$coefficients) == "InParty_food:cogresources"] <- "InParty:CRT"
names(food_quiz[[6]]$coefficients)[names(food_quiz[[6]]$coefficients) == "OutParty_food:cogresources"] <- "OutParty:CRT"
names(food_quiz[[6]]$coefficients)[names(food_quiz[[6]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"

#replace names 3-way table
names(food_quiz[[7]]$coefficients)[names(food_quiz[[7]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(food_quiz[[7]]$coefficients)[names(food_quiz[[7]]$coefficients) == "InParty_food:zero1(CRTall)"] <- "InParty:CRT"
names(food_quiz[[7]]$coefficients)[names(food_quiz[[7]]$coefficients) == "OutParty_food:zero1(CRTall)"] <- "OutParty:CRT"
names(food_quiz[[7]]$coefficients)[names(food_quiz[[7]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"
names(food_quiz[[7]]$coefficients)[names(food_quiz[[7]]$coefficients) == "InParty_food:zero1(PSIDstrength):zero1(CRTall)"] <- "InParty:PIDstrength:CRT"
names(food_quiz[[7]]$coefficients)[names(food_quiz[[7]]$coefficients) == "OutParty_food:zero1(PSIDstrength):zero1(CRTall)"] <- "OutParty:PIDstrength:CRT"

names(food_quiz[[8]]$coefficients)[names(food_quiz[[8]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(food_quiz[[8]]$coefficients)[names(food_quiz[[8]]$coefficients) == "InParty_food:zero1(NFC)"] <- "InParty:CRT"
names(food_quiz[[8]]$coefficients)[names(food_quiz[[8]]$coefficients) == "OutParty_food:zero1(NFC)"] <- "OutParty:CRT"
names(food_quiz[[8]]$coefficients)[names(food_quiz[[8]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"
names(food_quiz[[8]]$coefficients)[names(food_quiz[[8]]$coefficients) == "InParty_food:zero1(PSIDstrength):zero1(NFC)"] <- "InParty:PIDstrength:CRT"
names(food_quiz[[8]]$coefficients)[names(food_quiz[[8]]$coefficients) == "OutParty_food:zero1(PSIDstrength):zero1(NFC)"] <- "OutParty:PIDstrength:CRT"

names(food_quiz[[9]]$coefficients)[names(food_quiz[[9]]$coefficients) == "cogresources"] <- "CRT"
names(food_quiz[[9]]$coefficients)[names(food_quiz[[9]]$coefficients) == "InParty_food:cogresources"] <- "InParty:CRT"
names(food_quiz[[9]]$coefficients)[names(food_quiz[[9]]$coefficients) == "OutParty_food:cogresources"] <- "OutParty:CRT"
names(food_quiz[[9]]$coefficients)[names(food_quiz[[9]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"
names(food_quiz[[9]]$coefficients)[names(food_quiz[[9]]$coefficients) == "InParty_food:zero1(PSIDstrength):cogresources"] <- "InParty:PIDstrength:CRT"
names(food_quiz[[9]]$coefficients)[names(food_quiz[[9]]$coefficients) == "OutParty_food:zero1(PSIDstrength):cogresources"] <- "OutParty:PIDstrength:CRT"
summary(food_quiz[[6]])
stargazer(food_quiz[[1]], food_quiz[[4]] , food_quiz[[7]], food_quiz[[2]], food_quiz[[5]], food_quiz[[8]],food_quiz[[6]], food_quiz[[9]], title="Study 3: Number of Correct Quiz Items in the Food Irradiation Experiment: Party Cues, Reflection and Partisan Social Identity Strength", align=TRUE, order=c(1,2,3,4,11,12, 13,14,15,16,17,5,6,7,8,9,10), covariate.labels=c("In-party cue", "Out-party cue", "PSID","Cognitive resource", "In-party * PSID", "Out-party * PSID", "In-party * Cog", "Out-party * Cog", "PSID * Cog", "In-party * PSID * Cog", "Out-party * PSID * Cog", "Age", "Female", "Race: non-white", "Education: Some college", "Education: College", "Party: Republican", "Constant"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "+p<.1; *p<0.05", column.sep.width = "0.5pt",
          no.space=TRUE,font.size="tiny" , out = "Study3_quiz.tex",dep.var.caption = "Quiz result",column.labels = c("CRT", "NFC", "Cog resources"), column.separate = c(3, 3, 2), dep.var.labels.include = F,label="tab:stud4_quiz", digits=2)


## CRT at 0 or -1SD
m0 <- lm(zero1(Quiz_correct)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(Quiz_correct)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(Quiz_correct)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

##NfC plots belonging to Figure for Farm Policy
## NFC at 0 or -1SD
m0 <- lm(zero1(Quiz_correct)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## NFC at mean
m1 <- lm(zero1(Quiz_correct)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## NFC at +1
m2 <- lm(zero1(Quiz_correct)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

## Cog resources at -1
m0 <- lm(zero1(Quiz_correct)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(zero1(Quiz_correct)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(zero1(Quiz_correct)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
food_words<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+geom_line(aes(linetype=Cue, color=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effect of Party Cues on Quiz Results ")+geom_ribbon(aes(ymin=lb,ymax=ub, fill=Cue),alpha=.4)+geom_hline(yintercept = 0,lty="dashed")+scale_fill_manual(values=c("dark green", "red"))+scale_colour_manual(values=c("black", "black")) + theme(strip.text.y = element_text(angle = 360), legend.position="bottom") 
ggsave(food_words, file="study3_food_quiz.pdf",width=8,height=6)

### Appendix C.5: Inspection of the Mechanism: Quiz results in Farm Subsidy Experiment---------------------

#main effects
farm_quiz<-list()
summary(farm_quiz[[1]]<-lm(zero1(Farm_Quiz_correct)~InParty_farm + OutParty_farm + zero1(PSIDstrength) + zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) 
summary(farm_quiz[[2]]<-lm(zero1(Farm_Quiz_correct)~InParty_farm + OutParty_farm + zero1(PSIDstrength) + zero1(NFC)+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data)))
summary(farm_quiz[[3]]<-lm(zero1(Farm_Quiz_correct)~InParty_farm + OutParty_farm + zero1(PSIDstrength) +cogresources + age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1)))

#Twoway
summary(farm_quiz[[4]]<-lm(zero1(Farm_Quiz_correct)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+zero1(CRTall)+InParty_farm*zero1(CRTall)+OutParty_farm*zero1(CRTall) +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,data, CRT_honest==1)) #CRT
summary(farm_quiz[[5]]<-lm(zero1(Farm_Quiz_correct)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+zero1(NFC)+InParty_farm*zero1(NFC)+OutParty_farm*zero1(NFC) +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + zero1(NFC)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,data)) #NFC
summary(farm_quiz[[6]]<-lm(zero1(Farm_Quiz_correct)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+cogresources+InParty_farm*cogresources+OutParty_farm*cogresources +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + cogresources*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy  ,data, CRT_honest==1)) #cog resources

#Three way
summary(farm_quiz[[7]]<-lm(log1p(Farm_time_Page_Submit)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+zero1(CRTall)+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*zero1(CRTall)+OutParty_farm*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_farm*zero1(PSIDstrength)*zero1(CRTall)+OutParty_farm*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(farm_quiz[[8]]<-lm(log1p(Farm_time_Page_Submit)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+zero1(NFC)+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*zero1(NFC)+OutParty_farm*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_farm*zero1(PSIDstrength)*zero1(NFC)+OutParty_farm*zero1(PSIDstrength)*zero1(NFC) + age+female+ non_white +as.factor(edu)+Republican_dummy,data)) #NFC
summary(farm_quiz[[9]]<-lm(log1p(Farm_time_Page_Submit)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+cogresources+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*cogresources+OutParty_farm*cogresources+zero1(PSIDstrength)*cogresources+InParty_farm*zero1(PSIDstrength)*cogresources+OutParty_farm*zero1(PSIDstrength)*cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #Cog resources

#replace names 1 way model
names(farm_quiz[[1]]$coefficients)[names(farm_quiz[[1]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(farm_quiz[[2]]$coefficients)[names(farm_quiz[[2]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(farm_quiz[[3]]$coefficients)[names(farm_quiz[[3]]$coefficients) == "cogresources"] <- "CRT"

#replace names 2 way model
names(farm_quiz[[4]]$coefficients)[names(farm_quiz[[4]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(farm_quiz[[4]]$coefficients)[names(farm_quiz[[4]]$coefficients) == "InParty_farm:zero1(CRTall)"] <- "InParty:CRT"
names(farm_quiz[[4]]$coefficients)[names(farm_quiz[[4]]$coefficients) == "OutParty_farm:zero1(CRTall)"] <- "OutParty:CRT"
names(farm_quiz[[4]]$coefficients)[names(farm_quiz[[4]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"

names(farm_quiz[[5]]$coefficients)[names(farm_quiz[[5]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(farm_quiz[[5]]$coefficients)[names(farm_quiz[[5]]$coefficients) == "InParty_farm:zero1(NFC)"] <- "InParty:CRT"
names(farm_quiz[[5]]$coefficients)[names(farm_quiz[[5]]$coefficients) == "OutParty_farm:zero1(NFC)"] <- "OutParty:CRT"
names(farm_quiz[[5]]$coefficients)[names(farm_quiz[[5]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"

names(farm_quiz[[6]]$coefficients)[names(farm_quiz[[6]]$coefficients) == "cogresources"] <- "CRT"
names(farm_quiz[[6]]$coefficients)[names(farm_quiz[[6]]$coefficients) == "InParty_farm:cogresources"] <- "InParty:CRT"
names(farm_quiz[[6]]$coefficients)[names(farm_quiz[[6]]$coefficients) == "OutParty_farm:cogresources"] <- "OutParty:CRT"
names(farm_quiz[[6]]$coefficients)[names(farm_quiz[[6]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"

#replace names 3-way table
names(farm_quiz[[7]]$coefficients)[names(farm_quiz[[7]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(farm_quiz[[7]]$coefficients)[names(farm_quiz[[7]]$coefficients) == "InParty_farm:zero1(CRTall)"] <- "InParty:CRT"
names(farm_quiz[[7]]$coefficients)[names(farm_quiz[[7]]$coefficients) == "OutParty_farm:zero1(CRTall)"] <- "OutParty:CRT"
names(farm_quiz[[7]]$coefficients)[names(farm_quiz[[7]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"
names(farm_quiz[[7]]$coefficients)[names(farm_quiz[[7]]$coefficients) == "InParty_farm:zero1(PSIDstrength):zero1(CRTall)"] <- "InParty:PIDstrength:CRT"
names(farm_quiz[[7]]$coefficients)[names(farm_quiz[[7]]$coefficients) == "OutParty_farm:zero1(PSIDstrength):zero1(CRTall)"] <- "OutParty:PIDstrength:CRT"

names(farm_quiz[[8]]$coefficients)[names(farm_quiz[[8]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(farm_quiz[[8]]$coefficients)[names(farm_quiz[[8]]$coefficients) == "InParty_farm:zero1(NFC)"] <- "InParty:CRT"
names(farm_quiz[[8]]$coefficients)[names(farm_quiz[[8]]$coefficients) == "OutParty_farm:zero1(NFC)"] <- "OutParty:CRT"
names(farm_quiz[[8]]$coefficients)[names(farm_quiz[[8]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"
names(farm_quiz[[8]]$coefficients)[names(farm_quiz[[8]]$coefficients) == "InParty_farm:zero1(PSIDstrength):zero1(NFC)"] <- "InParty:PIDstrength:CRT"
names(farm_quiz[[8]]$coefficients)[names(farm_quiz[[8]]$coefficients) == "OutParty_farm:zero1(PSIDstrength):zero1(NFC)"] <- "OutParty:PIDstrength:CRT"

names(farm_quiz[[9]]$coefficients)[names(farm_quiz[[9]]$coefficients) == "cogresources"] <- "CRT"
names(farm_quiz[[9]]$coefficients)[names(farm_quiz[[9]]$coefficients) == "InParty_farm:cogresources"] <- "InParty:CRT"
names(farm_quiz[[9]]$coefficients)[names(farm_quiz[[9]]$coefficients) == "OutParty_farm:cogresources"] <- "OutParty:CRT"
names(farm_quiz[[9]]$coefficients)[names(farm_quiz[[9]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"
names(farm_quiz[[9]]$coefficients)[names(farm_quiz[[9]]$coefficients) == "InParty_farm:zero1(PSIDstrength):cogresources"] <- "InParty:PIDstrength:CRT"
names(farm_quiz[[9]]$coefficients)[names(farm_quiz[[9]]$coefficients) == "OutParty_farm:zero1(PSIDstrength):cogresources"] <- "OutParty:PIDstrength:CRT"

stargazer(farm_quiz[[1]], farm_quiz[[4]], farm_quiz[[7]], farm_quiz[[2]],farm_quiz[[5]], farm_quiz[[8]],farm_quiz[[3]],farm_quiz[[6]], farm_quiz[[9]], title="Study 3: Number of Correct Quiz Items in the Farm Subsidy Experiment: party cues, reflection and social identity strength", align=TRUE, order=c(1,2,3,4,11,12, 13,14,15,16,17,5,6,7,8,9,10), covariate.labels=c("In-party cue", "Out-party cue", "PSID","Cognitive resource", "In-party * PSID", "Out-party * PSID", "In-party * Cog", "Out-party * Cog", "PSID * Cog", "In-party * PSID * Cog", "Out-party * PSID * Cog", "Age", "Female", "Race: non-white", "Education: Some college", "Education: College", "Party: Republican", "Constant"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "+p<.1; *p<0.05", column.sep.width = "1pt",
          no.space=TRUE,font.size="tiny" , out = "Study3_quiz_farm.tex",dep.var.caption = "Quiz result",column.labels = c("CRT", "NFC", "Cognitive resources"), column.separate = c(3, 3, 3), dep.var.labels.include = F,label="tab:stud4_quiz_farm", digits=2)

m0 <- lm(zero1(Farm_Quiz_correct)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(Farm_Quiz_correct)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(Farm_Quiz_correct)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

##NfC plots belonging to Figure for Farm Policy
## NFC at 0 or -1SD
m0 <- lm(zero1(Farm_Quiz_correct)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## NFC at mean
m1 <- lm(zero1(Farm_Quiz_correct)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## NFC at +1
m2 <- lm(zero1(Farm_Quiz_correct)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

## Cog resources at -1
m0 <- lm(zero1(Farm_Quiz_correct)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(zero1(Farm_Quiz_correct)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(zero1(Farm_Quiz_correct)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
farm_quiz<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+geom_line(aes(linetype=Cue, color=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effect of Party Cues on Quiz Results ")+geom_ribbon(aes(ymin=lb,ymax=ub, fill=Cue),alpha=.4)+geom_hline(yintercept = 0,lty="dashed")+scale_fill_manual(values=c("dark green", "red"))+scale_colour_manual(values=c("black", "black")) + theme(strip.text.y = element_text(angle = 360), legend.position="bottom") 
ggsave(farm_quiz, file="study3_farm_quiz.pdf",width=8,height=6)

### Appendix C.6: Sample Characteristics-------------------------

table(data$female)
994/(994+916)

table(data$non_white)
357/(1553+357)

median(data$age,na.rm=T)
mean(data$age,na.rm=T)
sd(data$age,na.rm=T)

table(data$edu)
750/(784+750+376)

#systematic drop-out
data$farm_dropout<-ifelse(is.na(data$Farm_dv_support_rec),1,0)

dropout<-list()
summary(dropout[[1]]<-glm(data$farm_dropout~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(CRTall) + age+female+ non_white +as.factor(edu)+Republican_dummy, data=data, family="binomial"))
summary(dropout[[2]]<-glm(data$farm_dropout~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(NFC) + age+female+ non_white +as.factor(edu)+Republican_dummy, data=data, family="binomial"))
summary(dropout[[3]]<-glm(data$farm_dropout~InParty_food+OutParty_food+zero1(PSIDstrength)+cogresources + age+female+ non_white +as.factor(edu)+Republican_dummy, data=data, family="binomial"))

stargazer(dropout[[1]], dropout[[2]], dropout[[3]], title="Study 3: Drop-out between Food Irradiation and Farm Subsidy Experiment", align=TRUE , covariate.labels=c("In-party cue", "Out-party cue", "Partisan Identity Strength (PSID)","CRT", "NFC", "Cognitive resources", "Age", "Female", "Race: non-white", "Education: Some college", "Education: College", "Party: Republican", "Constant"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "Unstandardized coefficients from logistic regression; +p<.1; *p<0.05", column.sep.width = "1pt",
          no.space=TRUE,font.size="tiny" , out = "Study3_dropout.tex",dep.var.caption = "Drop-out",column.labels = c("CRT", "NFC", "Cognitive resources"), column.separate = c(1, 1,1), dep.var.labels.include = F,label="tab:stud4_dropout", digits=2)


### Appendix C.8: Partisan Social Identity Strength----------------------------------

#Factor structure of PID strength
huddy_latent<-'pid =~ NA*huddy1 +huddy2+huddy3+huddy4+huddy5+huddy6+huddy7+huddy8
pid ~~ 1*pid'

fit <- cfa(huddy_latent, ordered=c("huddy1", "huddy2", "huddy3", "huddy4", "huddy5", "huddy6", "huddy7", "huddy8"), data=data)
parameterEstimates(fit, standardized=TRUE)
p<-parameterEstimates(fit, standardized=TRUE) %>%  dplyr::select(std.all, pvalue)
p <- p[-c(9:58), ] 
names(p) <- c("Standardized Factor Loading", "p-value")
p<-xtable(caption = "Study 3 Partisan Social Identity Strength: Standardized Factor Loadings", label = "tab:cfaPID4", p)
print(p, type="latex", file="Study3_PID.tex", caption.placement="top")

#Descriptives
psych::alpha(mapply(function(x)zero1(as.numeric(x)),with(data,data.frame(huddy1, huddy2, huddy3, huddy4, huddy5, huddy6, huddy7, huddy8))),check.keys = T)
psych::omega(mapply(function(x)zero1(as.numeric(x)),with(data,data.frame(huddy1, huddy2, huddy3, huddy4, huddy5, huddy6, huddy7, huddy8))),check.keys = T)
summary(data$PSIDstrength)
sd(data$PSIDstrength,na.rm=T)
kurtosis(data$PSIDstrength, na.rm=T)
skewness(data$PSIDstrength, na.rm=T)

#Histogram of PID strenght
ggplot(data, aes(x = PSIDstrength)) + geom_histogram(binwidth = 0.01)+theme_bw()+labs(x="Partisan Social Identity Strength", y="Count")
#save results
ggsave("PID3_distribution.pdf",width=8,height=4)



### Appendix C.9: Cognitive Resources: Need for Coginition---------------------
nfc_latent<-'nfc =~ NA*NFC_1 + NFC_2 + NFC_3_rec + NFC_4_rec + NFC_5_rec + NFC_7_rec+NFC_10+NFC_11+NFC_12_rec+NFC_13
nfc~~1*nfc'
fit <- cfa(nfc_latent, ordered = c("NFC_1", "NFC_2", "NFC_3_rec", "NFC_4_rec", "NFC_5_rec", "NFC_7_rec", "NFC_10", "NFC_11", "NFC_12_rec", "NFC_13"), data=data)
p<-parameterEstimates(fit, standardized=TRUE) %>%  dplyr::select(std.all, pvalue)
p <- p[-c(11:82), ] 
p<-xtable(caption = "Need for Cognition: Standardized Factor Loadings", label = "tab:cfaNFC4", p)
names(p) <- c("Standardized Factor Loading", "p-value")
print(p, type="latex", file="Study3_CFA.tex", caption.placement="top")

#Histogram of NFC
ggplot(data, aes(x = NFC)) + geom_histogram(binwidth = 0.01)+theme_bw()+labs(x="Need for Cognition", y="Count")
#save results
ggsave("NFC3_distribution.pdf",width=8,height=4)

#Descriptives
psych::alpha(mapply(function(x)zero1(as.numeric(x)),with(data,data.frame(NFC_1, NFC_2, NFC_3_rec, NFC_4_rec, NFC_5_rec, NFC_7_rec, NFC_10, NFC_11, NFC_12_rec, NFC_13))),check.keys = T) #alpha is very high
psych::omega(mapply(function(x)zero1(as.numeric(x)),with(data,data.frame(NFC_1, NFC_2, NFC_3_rec, NFC_4_rec, NFC_5_rec, NFC_7_rec, NFC_10, NFC_11, NFC_12_rec, NFC_13))),check.keys = T) #alpha is very high
summary(data$NFC)
sd(data$NFC,na.rm=T)
kurtosis(data$NFC, na.rm=T)
skewness(data$NFC, na.rm=T)


### Appendix C.9: Cognitive Resources: Cognitive Reflection Test---------------------

psych::alpha(mapply(function(x)zero1(as.numeric(x)),with(data,data.frame(CRT1,CRT2,CRT3,CRT4,CRT5,CRT6,CRT7))),check.keys = T) #alpha is very high
psych::omega(mapply(function(x)zero1(as.numeric(x)),with(data,data.frame(CRT1,CRT2,CRT3,CRT4,CRT5,CRT6,CRT7))),check.keys = T) #alpha is very high
summary(zero1(data$CRTall))
sd(zero1(data$CRTall),na.rm=T)
kurtosis(data$CRTall, na.rm=T)
skewness(data$CRTall, na.rm=T)

#Histogram of CRT
ggplot(data, aes(x = zero1(CRTall))) + geom_histogram(binwidth = 0.01)+theme_bw()+labs(x="Cognitive Reflection Test", y="Count")
#save results
ggsave("CRT3_distribution.pdf",width=8,height=4)

#Tetrachoric correlations
data_crt<-data.frame(data$CRT1,  data$CRT2, data$CRT3, data$CRT4, data$CRT5, data$CRT6, data$CRT7)
poly_values = polychoric(data_crt)
items_polychoric = poly_values$rho 
items_polychoric[lower.tri(items_polychoric)] <- NA #remove lower part of the triangle
p<-xtable(caption = "Study 3: Tetrachoric Correlations for Cognitive Reflection Test", label = "tab:corCRT4", items_polychoric)
names(p) <- c("CRT1", "CRT2", "CRT3", "CRT4", "CRT5", "CRT6", "CRT7")
rownames(p) <- c("CRT1", "CRT2", "CRT3", "CRT4", "CRT5", "CRT6", "CRT7")
print(p, type="latex", file="Study3_CRT.tex", caption.placement="top")

### Appendix C.9: Cognitive Resources: Latent Cogntive Resources---------------------

latent <- ' cogresources  =~ NA*CRT1+CRT2+CRT3+CRT4+CRT5+CRT6+CRT7+NFC_1+NFC_2+NFC_3_rec+NFC_4_rec+NFC_5_rec+NFC_7_rec+NFC_10+ NFC_11+ NFC_12_rec+ NFC_13
# fix variance of latent variable
cogresources ~~ 1*cogresources'

fit <- cfa(latent, ordered=c("CRT1", "CRT2", "CRT3", "CRT4", "CRT5", "CRT6", "CRT7", "NFC_1", "NFC_2", "NFC_3_rec", "NFC_4_rec", "NFC_5_rec", "NFC_7_rec", "NFC_10", "NFC_11", "NFC_12_rec", "NFC_13"), data=data)
summary(fit, fit.measures=TRUE)
p<-parameterEstimates(fit, standardized=TRUE) %>%  dplyr::select(std.all, pvalue)
p <- p[-c(18:117), ] 
p<-xtable(caption = "Study 3 Cognitive Resources: Standardized Factor Loadings", label = "tab:Cog4", p)
names(p) <- c("Standardized Factor Loading", "p-value")
rownames(p) <- c("CRT 1", "CRT 2", "CRT 3", "CRT 4", "CRT 5", "CRT 6", "CRT 7", "NFC 1", "NFC 2", "NFC 3", "NFC 4", "NFC 5", "NFC 6", "NFC 7", "NFC 8", "NFC 9", "NFC 10")
print(p, type="latex", file="Study3_cog.tex", caption.placement="top")

#Histogram 
ggplot(data, aes(x = cogresources)) + geom_histogram(binwidth = 0.01)+theme_bw()+ labs(x="Cognitive Resources", y="Count")
#save results
ggsave("Cog3_distribution.pdf",width=8,height=4)

#Descriptives
psych::alpha(mapply(function(x)zero1(as.numeric(x)),with(data,data.frame(NFC_1, NFC_2, NFC_3_rec, NFC_4_rec, NFC_5_rec, NFC_7_rec, NFC_10, NFC_11, NFC_12_rec, NFC_13, CRT1, CRT2, CRT3, CRT4, CRT5, CRT6, CRT7))),check.keys = T) #alpha is very high
psych::omega(mapply(function(x)zero1(as.numeric(x)),with(data,data.frame(NFC_1, NFC_2, NFC_3_rec, NFC_4_rec, NFC_5_rec, NFC_7_rec, NFC_10, NFC_11, NFC_12_rec, NFC_13, CRT1, CRT2, CRT3, CRT4, CRT5, CRT6, CRT7))),check.keys = T) #alpha is very high
summary(zero1(data$cogresources))
sd(zero1(data$cogresources),na.rm=T)
skewness(zero1(data$cogresources), na.rm=T)
kurtosis(zero1(data$cogresources), na.rm=T)


### Appendix C.10: Randomization checks Food Irradiation---------------------
balance_crt<-lm(zero1(CRTall)~as.factor(data$treatment), data=data)
balance_nfc<-lm(NFC~as.factor(data$treatment), data=data)
balance_cog<-lm(cogresources~as.factor(data$treatment), data=data)
balance_pid<-lm(PSIDstrength~as.factor(data$treatment), data=data)

stargazer(balance_crt, balance_nfc, balance_cog, balance_pid, title="Study 3 Food Irradiation Experiment: balance checks of moderators", align=TRUE, 
          covariate.labels=c("Democrats support", "Republicans support"), 
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          star.cutoffs=c(0.05), 
          notes.append = FALSE, 
          notes = "*p<0.05", 
          no.space=TRUE,out = "Study3Balance.tex",dep.var.labels =c("CRT", "NFC", "Cognitive resources", "Party Identity Strength"),label="tab:Study4balance", digits=2)

balance_crt<-lm(zero1(CRTall)~InParty_food+OutParty_food, data=data)
balance_nfc<-lm(NFC~InParty_food+OutParty_food, data=data)
balance_cog<-lm(cogresources~InParty_food+OutParty_food, data=data)
balance_pid<-lm(PSIDstrength~InParty_food+OutParty_food, data=data)

stargazer(balance_crt, balance_nfc, balance_cog, balance_pid, title="Study 3 Food Irradiation Experiment: balance checks of moderators per cue condition", align=TRUE, 
          covariate.labels=c("In-party cue", "Out-party cue"), 
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          star.cutoffs=c(0.05), 
          notes.append = FALSE, 
          notes = "*p<0.05", 
          no.space=TRUE,out = "Study3Balance2.tex",dep.var.labels =c("CRT", "NFC", "Cognitive resources", "Party Identity Strength"),label="tab:Study4balance2", digits=2)

#covariates per condition
balanceSex1<-glm(data$female~as.factor(data$treatment), data=data, family=binomial(link="logit"))
balanceAge1<-lm(data$age~as.factor(data$treatment),data=data)
balanceEdu1<-polr(as.factor(data$edu)~as.factor(data$treatment), data=data, Hess=TRUE)
balanceRace1<-glm(data$non_white~as.factor(data$treatment),data=data, family=binomial(link="logit"))
balanceParty1<-glm(data$Republican_dummy~as.factor(data$treatment),data=data, family=binomial(link="logit"))

#Extract results for models
stargazer(balanceSex1, balanceAge1, balanceEdu1, balanceRace1, balanceParty1, title="Study 3 Food Irradiation Experiment: Balance Checks Demographics", align=TRUE, 
          dep.var.labels=c("Sex", "Age", "Education", "Non-white", "Republican Party"), 
          covariate.labels=c("Democrats support", "Republicans support"), 
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          star.cutoffs=c(0.05), 
          notes = "*p<0.05", 
          notes.append = FALSE, 
          no.space=TRUE,out = "Study3BalanceDem_1.tex", label="tab:balanceDemstudy4_1", digits=2)

#covariates
balanceSex<-glm(data$female~InParty_food+OutParty_food, data=data, family=binomial(link="logit"))
balanceAge<-lm(data$age~InParty_food+OutParty_food,data=data)
balanceEdu<-polr(as.factor(data$edu)~InParty_food+OutParty_food, data=data, Hess=TRUE)
balanceRace<-glm(data$non_white~InParty_food+OutParty_food,data=data, family=binomial(link="logit"))
balanceParty<-glm(data$Republican_dummy~InParty_food+OutParty_food,data=data, family=binomial(link="logit"))

#Extract results for models
stargazer(balanceSex, balanceAge, balanceEdu, balanceRace, balanceParty, title="Study 3 Food Irradiation Experiment: Balance Checks Demographics", align=TRUE, 
          dep.var.labels=c("Sex", "Age", "Education", "Non-white", "Republican Party"), 
          covariate.labels=c("In-party cue", "Out-party cue"), 
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          star.cutoffs=c(0.05), 
          notes = "*p<0.05", 
          notes.append = FALSE, 
          no.space=TRUE,out = "Study3BalanceDem.tex", label="tab:balanceDemstudy4", digits=2)

### Appendix C.10: Randomization checks Farm Subsidy---------------------

balance_crt_farm<-lm(zero1(CRTall)~as.factor(data$treatment_farm), data=data)
balance_nfc_farm<-lm(NFC~as.factor(data$treatment_farm), data=data)
balance_cog_farm<-lm(cogresources~as.factor(data$treatment_farm), data=data)
balance_pid_farm<-lm(PSIDstrength~as.factor(data$treatment_farm), data=data)

stargazer(balance_crt_farm, balance_nfc_farm, balance_cog_farm, balance_pid_farm, title="Study 3 Farm Subsidy Experiment: balance checks of moderators", align=TRUE, 
          covariate.labels=c("Democrats support", "Republicans support"), 
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          star.cutoffs=c(0.05), 
          notes.append = FALSE, 
          notes = "*p<0.05", 
          no.space=TRUE,out = "Study3Balance_farm.tex",dep.var.labels =c("CRT", "NFC", "Cognitive resources", "Party Identity Strength"),label="tab:Study4balance_farm", digits=2)

balance_crt<-lm(zero1(CRTall)~InParty_farm+OutParty_farm, data=data)
balance_nfc<-lm(NFC~InParty_farm+OutParty_farm, data=data)
balance_cog<-lm(cogresources~InParty_farm+OutParty_farm, data=data)
balance_pid<-lm(PSIDstrength~InParty_farm+OutParty_farm, data=data)
summary(balance_crt)
stargazer(balance_crt, balance_nfc, balance_cog, balance_pid, title="Study 3 Farm Subsidy Experiment: balance checks of moderators per cue condition", align=TRUE, 
          covariate.labels=c("In-party cue", "Out-party cue"), 
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          star.cutoffs=c(0.05), 
          notes.append = FALSE, 
          notes = "*p<0.05", 
          no.space=TRUE,out = "Study3Balance2_farm.tex",dep.var.labels =c("CRT", "NFC", "Cognitive resources", "Party Identity Strength"),label="tab:Study4balance2_farm", digits=2)

#covariates per condition
balanceSex1<-glm(data$female~as.factor(data$treatment_farm), data=data, family=binomial(link="logit"))
balanceAge1<-lm(data$age~as.factor(data$treatment_farm),data=data)
balanceEdu1<-polr(as.factor(data$edu)~as.factor(data$treatment_farm), data=data, Hess=TRUE)
balanceRace1<-glm(data$non_white~as.factor(data$treatment_farm),data=data, family=binomial(link="logit"))
balanceParty1<-glm(data$Republican_dummy~as.factor(data$treatment_farm),data=data, family=binomial(link="logit"))

#Extract results for models
stargazer(balanceSex1, balanceAge1, balanceEdu1, balanceRace1, balanceParty1, title="Study 3 Farm Subsidy Experiment: Balance Checks Demographics", align=TRUE, 
          dep.var.labels=c("Sex", "Age", "Education", "Non-white", "Republican Party"), 
          covariate.labels=c("Democrats support", "Republicans support"), 
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          star.cutoffs=c(0.05), 
          notes = "*p<0.05", 
          notes.append = FALSE, 
          no.space=TRUE,out = "Study3BalanceDem_farm_1.tex", label="tab:balanceDemstudy4_1_farm", digits=2)

#covariates
balanceSex<-glm(data$female~InParty_farm+OutParty_farm, data=data, family=binomial(link="logit"))
balanceAge<-lm(data$age~InParty_farm+OutParty_farm,data=data)
balanceEdu<-polr(as.factor(data$edu)~InParty_farm+OutParty_farm, data=data, Hess=TRUE)
balanceRace<-glm(data$non_white~InParty_farm+OutParty_farm,data=data, family=binomial(link="logit"))
balanceParty<-glm(data$Republican_dummy~InParty_farm+OutParty_farm,data=data, family=binomial(link="logit"))

#Extract results for models
stargazer(balanceSex, balanceAge, balanceEdu, balanceRace, balanceParty, title="Study 3 Farm Subsidy Experiment: Balance Checks Demographics", align=TRUE, 
          dep.var.labels=c("Sex", "Age", "Education", "Non-white", "Republican Party"), 
          covariate.labels=c("In-party cue", "Out-party cue"), 
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          star.cutoffs=c(0.05), 
          notes = "*p<0.05", 
          notes.append = FALSE, 
          no.space=TRUE,out = "Study3BalanceDem_farm.tex", label="tab:balanceDemstudy4_farm", digits=2)



### Appendix C.11: Main effects of Food Irradiation and Farm Subsidy Experiments-------------
main<-(lm(zero1(DV_irradiation)~InParty_food+OutParty_food+PSIDstrength+zero1(CRTall)+age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1)))
main1<-(lm(zero1(DV_irradiation)~InParty_food+OutParty_food+PSIDstrength+NFC+age+female+ non_white +as.factor(edu)+Republican_dummy,data))
main2<-(lm(zero1(DV_irradiation)~InParty_food+OutParty_food+PSIDstrength+cogresources+age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1)))

stargazer(main, main1, main2, title="Study 3 Food Irradiation Experiment: Main Effect of Party Cues on Support for Food Irradiation", align=TRUE, 
          covariate.labels=c("In-Party cue", "Out-Party cue", "PID Strength","CRT", "NfC", "Cognitive resources", "Age", "Female", "Race: non-white", "Education: Some college", "Education: College", "Party: Republican"), 
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.05), 
          notes = "*p<0.05", 
          no.space=TRUE,out = "Study3_Foodmain.tex",dep.var.caption = "Policy support",dep.var.labels.include = F,label="tab:foodmain4", digits=2)

main<-(lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm+PSIDstrength+ zero1(CRTall)+age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1)))
main1<-(lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm+PSIDstrength+NFC+age+female+ non_white +as.factor(edu)+Republican_dummy,data))
main2<-(lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm+PSIDstrength+cogresources+age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1)))

stargazer(main, main1, main2, title="Study 3 Farm Subsidy Experiment: Main Effect of Party Cues on Support for Farm Subsidies", align=TRUE, 
          covariate.labels=c("In-Party cue", "Out-Party cue", "PID Strength","CRT", "NfC", "Cognitive resources", "Age", "Female", "Race: non-white", "Education: Some college", "Education: College", "Party: Republican"), 
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.05), 
          notes = "*p<0.05", 
          no.space=TRUE,out = "Study3_Farmmain.tex",dep.var.caption = "Policy support",dep.var.labels.include = F,label="tab:foodmain4_farm", digits=2)



### Appendix C.12: Direct replication of Kam 2005--------------

#Party Cue: 1 (strong or weak partisan, out-party endorses ban); 0.5 (leaning partisan, out- party endorses ban); 0 (no party cue); +0.5 (leaning partisan, in-party endorses ban); +1 (strong or weak partisan, in-party endorses ban).
data$PartyCue<-NA
data$PartyCue[data$pid1==1 & data$treatment==2]<--1
data$PartyCue[data$pid1==2 & data$treatment==3]<--1
data$PartyCue[data$pid4==1 & data$treatment==2]<--0.5
data$PartyCue[data$pid4==2 & data$treatment==3]<--0.5
data$PartyCue[data$treatment==1 & data$pid1==1]<--0
data$PartyCue[data$treatment==1 & data$pid1==2]<--0
data$PartyCue[data$treatment==1 & data$pid4==1]<--0
data$PartyCue[data$treatment==1 & data$pid4==2]<--0
data$PartyCue[data$treatment==3 & data$pid4==1]<-0.5
data$PartyCue[data$treatment==2 & data$pid4==2]<-0.5
data$PartyCue[data$treatment==3 & data$pid1==1]<-1
data$PartyCue[data$treatment==2 & data$pid1==2]<-1
#recode variable to range from 0 - 1
mean(zero1(data$DV_support),na.rm=T)
sd(zero1(data$DV_support),na.rm=T)

#NFC 18-item
summary(NFC18_kam<-(lm(zero1(data$DV_support_rec)~PartyCue*NFC,data=data)))
summary(NFC18<-(lm(zero1(data$DV_irradiation)~PartyCue*NFC,data=data)))
stargazer(NFC18_kam, NFC18, title="Study 3 Food Irradiation: Moderation of Party Cues Following Kam (2005)", align=TRUE, 
          dep.var.labels=c("Support for Ban of Food Irradiation"), 
          covariate.labels=c("Party Cue", "NfC", "Party Cue * NfC"), 
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          star.cutoffs=c(0.05), 
          notes = "OLS Regession models; *p<0.05", 
          notes.append = FALSE, 
          no.space=TRUE, out = "Study3_Kam.tex",dep.var.caption = "Policy support",dep.var.labels.include = F,label="tab:kam4", digits=2)
summary(NFC18_kam)


### Appendix C.13: Food Irradiation Experiment: item-by-item analysis ITEM 1--------------------

#Two-way
results_food<-list()
summary(results_food[[1]]<-lm(zero1(DV_support_rec)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(results_food[[2]]<-lm(zero1(DV_support_rec)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(NFC)*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)) #NFC
summary(results_food[[3]]<-lm(zero1(DV_support_rec)~InParty_food+OutParty_food + zero1(PSIDstrength)+cogresources+InParty_food*cogresources+OutParty_food*cogresources +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + cogresources*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #resources

#Three way
summary(results_food[[4]]<-lm(zero1(DV_support_rec)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_food*zero1(PSIDstrength)*zero1(CRTall)+OutParty_food*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(results_food[[5]]<-lm(zero1(DV_support_rec)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_food*zero1(PSIDstrength)*zero1(NFC)+OutParty_food*zero1(PSIDstrength)*zero1(NFC) + age+female+ non_white +as.factor(edu)+Republican_dummy,data)) #NFC
summary(results_food[[6]]<-lm(zero1(DV_support_rec)~InParty_food+OutParty_food+zero1(PSIDstrength)+cogresources+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*cogresources+OutParty_food*cogresources+zero1(PSIDstrength)*cogresources+InParty_food*zero1(PSIDstrength)*cogresources+OutParty_food*zero1(PSIDstrength)*cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #Cog resources

#replace names 2 way model
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "InParty_food:zero1(CRTall)"] <- "InParty:CRT"
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "OutParty_food:zero1(CRTall)"] <- "OutParty:CRT"
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"

names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "InParty_food:zero1(NFC)"] <- "InParty:CRT"
names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "OutParty_food:zero1(NFC)"] <- "OutParty:CRT"
names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"

names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "cogresources"] <- "CRT"
names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "InParty_food:cogresources"] <- "InParty:CRT"
names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "OutParty_food:cogresources"] <- "OutParty:CRT"
names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"

#replace names 3-way table
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "InParty_food:zero1(CRTall)"] <- "InParty:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "OutParty_food:zero1(CRTall)"] <- "OutParty:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "InParty_food:zero1(PSIDstrength):zero1(CRTall)"] <- "InParty:PIDstrength:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "OutParty_food:zero1(PSIDstrength):zero1(CRTall)"] <- "OutParty:PIDstrength:CRT"

names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "InParty_food:zero1(NFC)"] <- "InParty:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "OutParty_food:zero1(NFC)"] <- "OutParty:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "InParty_food:zero1(PSIDstrength):zero1(NFC)"] <- "InParty:PIDstrength:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "OutParty_food:zero1(PSIDstrength):zero1(NFC)"] <- "OutParty:PIDstrength:CRT"

names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "cogresources"] <- "CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "InParty_food:cogresources"] <- "InParty:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "OutParty_food:cogresources"] <- "OutParty:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "InParty_food:zero1(PSIDstrength):cogresources"] <- "InParty:PIDstrength:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "OutParty_food:zero1(PSIDstrength):cogresources"] <- "OutParty:PIDstrength:CRT"

stargazer(results_food[[1]], results_food[[4]], results_food[[2]], results_food[[5]],results_food[[3]], results_food[[6]], title="Study 3: Food Irradiation item 1 ``Support'': Policy support, party cues, cognitive resources and social
          identity strength", align=TRUE, order=c(1,2,3,4,11,12, 13,14,15,16,17,5,6,7,8,9,10), covariate.labels=c("In-party cue", "Out-party cue", "Partisan Identity Strength (PSID)","Cognitive resource", "In-party * PSID", "Out-party * PSID", "In-party * Cognitive", "Out-party * Cognitive", "PSID * Cognitive", "In-party * PSID * Cognitive", "Out-party * PSID * Cognitive", "Age", "Female", "Race: non-white", "Education: Some college", "Education: College", "Party: Republican", "Constant"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "+p<.1; *p<0.05", column.sep.width = "1pt",
          no.space=TRUE,font.size="tiny" , out = "Study3_item1.tex",dep.var.caption = "Policy support",column.labels = c("CRT", "NFC", "Cog resources"), column.separate = c(2, 2, 2), dep.var.labels.include = F,label="tab:stud4_item1", digits=2)


#CRT
m0 <- lm(zero1(DV_support_rec)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m0)
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(DV_support_rec)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m1)
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(DV_support_rec)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m2)
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

##NFC plots belonging to Figure 
## NFC at 0 or -1SD
m0 <- lm(zero1(DV_support_rec)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)-sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)-sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(DV_support_rec)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(DV_support_rec)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)+sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)+sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot_nfc$CRT,levels = c("-1 SD","Mean","+1 SD"))

#Cognitive resources
m0 <- lm(zero1(DV_support_rec)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(zero1(DV_support_rec)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(zero1(DV_support_rec)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
food_replication_1<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+geom_line(aes(linetype=Cue, color=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effect of Party Cues on Policy Support ")+geom_ribbon(aes(ymin=lb,ymax=ub, fill=Cue),alpha=.4)+geom_hline(yintercept = 0,lty="dashed")+scale_fill_manual(values=c("dark green", "red"))+scale_colour_manual(values=c("black", "black")) + theme(strip.text.y = element_text(angle = 360), legend.position="bottom")
ggsave(food_replication_1, file="study3_food_1.pdf",width=8,height=6)


### Appendix C.13: Food Irradiation Experiment: item-by-item analysis ITEM 2--------------------

#Two-way
results_food<-list()
summary(results_food[[1]]<-lm(zero1(DV_costs_rec)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(results_food[[2]]<-lm(zero1(DV_costs_rec)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(NFC)*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)) #NFC
summary(results_food[[3]]<-lm(zero1(DV_costs_rec)~InParty_food+OutParty_food + zero1(PSIDstrength)+cogresources+InParty_food*cogresources+OutParty_food*cogresources +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + cogresources*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #resources

#Three way
summary(results_food[[4]]<-lm(zero1(DV_costs_rec)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_food*zero1(PSIDstrength)*zero1(CRTall)+OutParty_food*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(results_food[[5]]<-lm(zero1(DV_costs_rec)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_food*zero1(PSIDstrength)*zero1(NFC)+OutParty_food*zero1(PSIDstrength)*zero1(NFC) + age+female+ non_white +as.factor(edu)+Republican_dummy,data)) #NFC
summary(results_food[[6]]<-lm(zero1(DV_costs_rec)~InParty_food+OutParty_food+zero1(PSIDstrength)+cogresources+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*cogresources+OutParty_food*cogresources+zero1(PSIDstrength)*cogresources+InParty_food*zero1(PSIDstrength)*cogresources+OutParty_food*zero1(PSIDstrength)*cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #Cog resources

#replace names 2 way model
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "InParty_food:zero1(CRTall)"] <- "InParty:CRT"
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "OutParty_food:zero1(CRTall)"] <- "OutParty:CRT"
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"

names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "InParty_food:zero1(NFC)"] <- "InParty:CRT"
names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "OutParty_food:zero1(NFC)"] <- "OutParty:CRT"
names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"

names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "cogresources"] <- "CRT"
names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "InParty_food:cogresources"] <- "InParty:CRT"
names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "OutParty_food:cogresources"] <- "OutParty:CRT"
names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"

#replace names 3-way table
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "InParty_food:zero1(CRTall)"] <- "InParty:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "OutParty_food:zero1(CRTall)"] <- "OutParty:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "InParty_food:zero1(PSIDstrength):zero1(CRTall)"] <- "InParty:PIDstrength:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "OutParty_food:zero1(PSIDstrength):zero1(CRTall)"] <- "OutParty:PIDstrength:CRT"

names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "InParty_food:zero1(NFC)"] <- "InParty:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "OutParty_food:zero1(NFC)"] <- "OutParty:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "InParty_food:zero1(PSIDstrength):zero1(NFC)"] <- "InParty:PIDstrength:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "OutParty_food:zero1(PSIDstrength):zero1(NFC)"] <- "OutParty:PIDstrength:CRT"

names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "cogresources"] <- "CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "InParty_food:cogresources"] <- "InParty:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "OutParty_food:cogresources"] <- "OutParty:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "InParty_food:zero1(PSIDstrength):cogresources"] <- "InParty:PIDstrength:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "OutParty_food:zero1(PSIDstrength):cogresources"] <- "OutParty:PIDstrength:CRT"

stargazer(results_food[[1]], results_food[[4]], results_food[[2]], results_food[[5]],results_food[[3]], results_food[[6]], title="Study 3: Food Irradiation item 2 ``Cost-benefit'': Policy support, party cues, cognitive resources and social
          identity strength", align=TRUE, order=c(1,2,3,4,11,12, 13,14,15,16,17,5,6,7,8,9,10), covariate.labels=c("In-party cue", "Out-party cue", "Partisan Identity Strength (PSID)","Cognitive resource", "In-party * PSID", "Out-party * PSID", "In-party * Cognitive", "Out-party * Cognitive", "PSID * Cognitive", "In-party * PSID * Cognitive", "Out-party * PSID * Cognitive", "Age", "Female", "Race: non-white", "Education: Some college", "Education: College", "Party: Republican", "Constant"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "+p<.1; *p<0.05", column.sep.width = "1pt",
          no.space=TRUE,font.size="tiny" , out = "Study3_item2.tex",dep.var.caption = "Policy support",column.labels = c("CRT", "NFC", "Cog resources"), column.separate = c(2, 2, 2), dep.var.labels.include = F,label="tab:stud4_item2", digits=2)


#CRT
m0 <- lm(zero1(DV_costs_rec)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m0)
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(DV_costs_rec)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m1)
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(DV_costs_rec)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m2)
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

##NFC plots belonging to Figure 
## NFC at 0 or -1SD
m0 <- lm(zero1(DV_costs_rec)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)-sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)-sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(DV_costs_rec)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(DV_costs_rec)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)+sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)+sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot_nfc$CRT,levels = c("-1 SD","Mean","+1 SD"))

#Cognitive resources
m0 <- lm(zero1(DV_costs_rec)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(zero1(DV_costs_rec)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(zero1(DV_costs_rec)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
food_replication_2<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+geom_line(aes(linetype=Cue, color=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effect of Party Cues on Policy Support ")+geom_ribbon(aes(ymin=lb,ymax=ub, fill=Cue),alpha=.4)+geom_hline(yintercept = 0,lty="dashed")+scale_fill_manual(values=c("dark green", "red"))+scale_colour_manual(values=c("black", "black")) + theme(strip.text.y = element_text(angle = 360), legend.position="bottom")
ggsave(food_replication_2, file="study3_food_2.pdf",width=8,height=6)




### Appendix C.13: Food Irradiation Experiment: item-by-item analysis ITEM 3--------------------

#Two-way
results_food<-list()
summary(results_food[[1]]<-lm(zero1(DV_bad_rec)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(results_food[[2]]<-lm(zero1(DV_bad_rec)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(NFC)*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)) #NFC
summary(results_food[[3]]<-lm(zero1(DV_bad_rec)~InParty_food+OutParty_food + zero1(PSIDstrength)+cogresources+InParty_food*cogresources+OutParty_food*cogresources +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + cogresources*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #resources

#Three way
summary(results_food[[4]]<-lm(zero1(DV_bad_rec)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_food*zero1(PSIDstrength)*zero1(CRTall)+OutParty_food*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(results_food[[5]]<-lm(zero1(DV_bad_rec)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_food*zero1(PSIDstrength)*zero1(NFC)+OutParty_food*zero1(PSIDstrength)*zero1(NFC) + age+female+ non_white +as.factor(edu)+Republican_dummy,data)) #NFC
summary(results_food[[6]]<-lm(zero1(DV_bad_rec)~InParty_food+OutParty_food+zero1(PSIDstrength)+cogresources+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*cogresources+OutParty_food*cogresources+zero1(PSIDstrength)*cogresources+InParty_food*zero1(PSIDstrength)*cogresources+OutParty_food*zero1(PSIDstrength)*cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #Cog resources

#replace names 2 way model
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "InParty_food:zero1(CRTall)"] <- "InParty:CRT"
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "OutParty_food:zero1(CRTall)"] <- "OutParty:CRT"
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"

names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "InParty_food:zero1(NFC)"] <- "InParty:CRT"
names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "OutParty_food:zero1(NFC)"] <- "OutParty:CRT"
names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"

names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "cogresources"] <- "CRT"
names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "InParty_food:cogresources"] <- "InParty:CRT"
names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "OutParty_food:cogresources"] <- "OutParty:CRT"
names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"

#replace names 3-way table
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "InParty_food:zero1(CRTall)"] <- "InParty:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "OutParty_food:zero1(CRTall)"] <- "OutParty:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "InParty_food:zero1(PSIDstrength):zero1(CRTall)"] <- "InParty:PIDstrength:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "OutParty_food:zero1(PSIDstrength):zero1(CRTall)"] <- "OutParty:PIDstrength:CRT"

names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "InParty_food:zero1(NFC)"] <- "InParty:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "OutParty_food:zero1(NFC)"] <- "OutParty:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "InParty_food:zero1(PSIDstrength):zero1(NFC)"] <- "InParty:PIDstrength:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "OutParty_food:zero1(PSIDstrength):zero1(NFC)"] <- "OutParty:PIDstrength:CRT"

names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "cogresources"] <- "CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "InParty_food:cogresources"] <- "InParty:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "OutParty_food:cogresources"] <- "OutParty:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "InParty_food:zero1(PSIDstrength):cogresources"] <- "InParty:PIDstrength:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "OutParty_food:zero1(PSIDstrength):cogresources"] <- "OutParty:PIDstrength:CRT"

stargazer(results_food[[1]], results_food[[4]], results_food[[2]], results_food[[5]],results_food[[3]], results_food[[6]], title="Study 3: Food Irradiation item 2 ``Good vs. Bad'': Policy support, party cues, cognitive resources and social
          identity strength", align=TRUE, order=c(1,2,3,4,11,12, 13,14,15,16,17,5,6,7,8,9,10), covariate.labels=c("In-party cue", "Out-party cue", "Partisan Identity Strength (PSID)","Cognitive resource", "In-party * PSID", "Out-party * PSID", "In-party * Cognitive", "Out-party * Cognitive", "PSID * Cognitive", "In-party * PSID * Cognitive", "Out-party * PSID * Cognitive", "Age", "Female", "Race: non-white", "Education: Some college", "Education: College", "Party: Republican", "Constant"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "+p<.1; *p<0.05", column.sep.width = "1pt",
          no.space=TRUE,font.size="tiny" , out = "Study3_item3.tex",dep.var.caption = "Policy support",column.labels = c("CRT", "NFC", "Cog resources"), column.separate = c(2, 2, 2), dep.var.labels.include = F,label="tab:stud4_item3", digits=2)


#CRT
m0 <- lm(zero1(DV_bad_rec)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m0)
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(DV_bad_rec)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m1)
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(DV_bad_rec)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m2)
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

##NFC plots belonging to Figure 
## NFC at 0 or -1SD
m0 <- lm(zero1(DV_bad_rec)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)-sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)-sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(DV_bad_rec)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(DV_bad_rec)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)+sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)+sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot_nfc$CRT,levels = c("-1 SD","Mean","+1 SD"))

#Cognitive resources
m0 <- lm(zero1(DV_bad_rec)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(zero1(DV_bad_rec)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(zero1(DV_bad_rec)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
food_replication_3<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+geom_line(aes(linetype=Cue, color=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effect of Party Cues on Policy Support ")+geom_ribbon(aes(ymin=lb,ymax=ub, fill=Cue),alpha=.4)+geom_hline(yintercept = 0,lty="dashed")+scale_fill_manual(values=c("dark green", "red"))+scale_colour_manual(values=c("black", "black")) + theme(strip.text.y = element_text(angle = 360), legend.position="bottom")
ggsave(food_replication_3, file="study3_food_3.pdf",width=8,height=6)



### Appendix C.14: Inspection of non-linearity: Food Irradiation Experiment---------------------

data$PSIDstrength_cats<-NA
data$PSIDstrength_cats[data$PSIDstrength<.4584]=0
data$PSIDstrength_cats[data$PSIDstrength>.4584 & data$PSIDstrength<.626]=1
data$PSIDstrength_cats[data$PSIDstrength>=.626]=2
data$PSIDstrength_cats <- factor(data$PSIDstrength_cats,levels = c(0,1,2), label=c("low", "modest", "high"))

#Food Irradiation models
#CRT
m0 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength_cats+OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength_cats')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength_cats')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength_cats+OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m1)
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength_cats')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength_cats')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength_cats+ OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m2)
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength_cats')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength_cats')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

#remove lines that are not necessary
forplot <- forplot[-c(3, 7,11,15,19,23), ] 
forplot$fake<-rep(1:3,6)
forplot$fake <- factor(forplot$fake,levels = c("1","2","3"))

##NFC plots belonging to Figure 
## NFC at 0 or -1SD
m0 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)-sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength_cats+OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)-sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength_cats')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength_cats')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength_cats+OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength_cats')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength_cats')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)+sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength_cats+ OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)+sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength_cats')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength_cats')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot_nfc$CRT,levels = c("-1 SD","Mean","+1 SD"))

#remove lines that are not necessary
forplot_nfc <- forplot_nfc[-c(3, 7,11,15,19,23), ] 
forplot_nfc$fake<-rep(1:3,6)
forplot_nfc$fake <- factor(forplot_nfc$fake,levels = c("1","2","3"))
forplot_nfc$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))


#Cognitive resources
m0 <- lm(zero1(DV_irradiation)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength_cats+ OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength_cats')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength_cats')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(zero1(DV_irradiation)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength_cats+OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength_cats')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength_cats')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(zero1(DV_irradiation)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength_cats+ OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength_cats')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength_cats')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))

#remove lines that are not necessary
forplot_cog <- forplot_cog[-c(3, 7,11,15,19,23), ] 
forplot_cog$fake<-rep(1:3,6)
forplot_cog$fake <- factor(forplot_cog$fake,levels = c("1","2","3"))
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))


##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
food_linear<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effects of Party Cues on Policy Support ")+geom_pointrange(aes(ymin=lb,ymax=ub, fill=Cue),alpha=1, position=position_dodge(width=0.2))+geom_hline(yintercept = 0,lty="dashed")+scale_colour_manual(values = c("dark green", "red")) +scale_x_discrete(labels = c("1" = "Weak","2" = "Modest", "3"="Strong"))+ theme(strip.text.y = element_text(angle = 360), legend.position="bottom")
ggsave(food_linear, file="study3_food_linear.pdf",width=8,height=6)

### Appendix C.14: Inspection of non-linearity: Farm Subsidy Experiment---------------------

## CRT at 0 or -1SD
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength_cats+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength_cats')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength_cats')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength_cats+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength_cats')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength_cats')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength_cats+ OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength_cats')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength_cats')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

#remove lines that are not necessary
forplot <- forplot[-c(3, 7,11,15,19,23), ] 
forplot$fake<-rep(1:3,6)
forplot$fake <- factor(forplot$fake,levels = c("1","2","3"))

##NfC plots belonging to Figure for Farm Policy
## NFC at 0 or -1SD
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength_cats+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength_cats')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength_cats')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## NFC at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength_cats+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength_cats')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength_cats')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## NFC at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength_cats+ OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength_cats')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength_cats')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot_nfc$CRT,levels = c("-1 SD","Mean","+1 SD"))
#remove lines that are not necessary
forplot_nfc <- forplot_nfc[-c(3, 7,11,15,19,23), ] 
forplot_nfc$fake<-rep(1:3,6)
forplot_nfc$fake <- factor(forplot_nfc$fake,levels = c("1","2","3"))

## Cog resources at -1
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength_cats+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength_cats')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength_cats')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength_cats+OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength_cats+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength_cats')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength_cats')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength_cats+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength_cats,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength_cats')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength_cats')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))
#remove lines that are not necessary
forplot_cog <- forplot_cog[-c(3, 7,11,15,19,23), ] 
forplot_cog$fake<-rep(1:3,6)
forplot_cog$fake <- factor(forplot_cog$fake,levels = c("1","2","3"))

##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
farm_linear<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effects of Party Cues on Policy Support ")+geom_pointrange(aes(ymin=lb,ymax=ub, fill=Cue),alpha=1, position=position_dodge(width=0.2))+geom_hline(yintercept = 0,lty="dashed")+scale_colour_manual(values = c("dark green", "red")) +scale_x_discrete(labels = c("1" = "Weak","2" = "Modest", "3"="Strong"))+ theme(strip.text.y = element_text(angle = 360), legend.position="bottom")
ggsave(farm_linear, file="study3_farm_linear.pdf",width=8,height=6)

### Appendix C.15: Results using the 3-item CRT battery---------------------

#make trait
data$CRT3item <- rowSums(with(data,data.frame(CRT1,CRT2,CRT3)),na.rm=T)
summary(zero1(data$CRT3item))
sd(zero1(data$CRT3item))

#Cor
cor.test(data$CRT3item, data$CRTall)

#CRT
m0 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRT3item),center=mean(zero1(CRT3item))-sd(zero1(CRT3item)),scale=F)*PSIDstrength+OutParty_food*scale(zero1(CRT3item),center=mean(zero1(CRT3item))-sd(zero1(CRT3item)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m0)
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRT3item),center=mean(zero1(CRT3item),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(CRT3item),center=mean(zero1(CRT3item),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m1)
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRT3item),center=mean(zero1(CRT3item))+sd(zero1(CRT3item)),scale=F)*PSIDstrength+ OutParty_food*scale(zero1(CRT3item),center=mean(zero1(CRT3item))+sd(zero1(CRT3item)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
summary(m2)
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("Food Irradiation\n Experiment")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

## CRT at 0 or -1SD
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRT3item),center=mean(zero1(CRT3item))-sd(zero1(CRT3item)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRT3item),center=mean(zero1(CRT3item))-sd(zero1(CRT3item)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRT3item),center=mean(zero1(CRT3item),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRT3item),center=mean(zero1(CRT3item),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRT3item),center=mean(zero1(CRT3item))+sd(zero1(CRT3item)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(CRT3item),center=mean(zero1(CRT3item))+sd(zero1(CRT3item)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_farm <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_farm$battery      <- c("Farm Subsidy\n Experiment")
forplot_farm$CRT <- factor(forplot_farm$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_farm)
forpaper$battery <- factor(forpaper$battery,levels = c("Food Irradiation\n Experiment","Farm Subsidy\n Experiment"))
crt3<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+geom_line(aes(linetype=Cue, color=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effect of Party Cues on Policy Support ")+geom_ribbon(aes(ymin=lb,ymax=ub, fill=Cue),alpha=.4)+geom_hline(yintercept = 0,lty="dashed")+scale_fill_manual(values=c("dark green", "red"))+scale_colour_manual(values=c("black", "black")) + theme(strip.text.y = element_text(angle = 360), legend.position="bottom")
ggsave(crt3, file="study3_crt3.pdf",width=8,height=6)

### Appendix C.16: Models where who "have seen the CRT" were excluded -------------------------------------

table(data$CRT_seen01)
458/(458+1450)
CRT_seen<-list()

#oneway
summary(CRT_seen[[1]]<-lm(zero1(DV_irradiation)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_seen01==0 & CRT_honest==1))) #CRT
summary(CRT_seen[[2]]<-lm(zero1(DV_irradiation)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_seen01==0 & CRT_honest==1))) #CRT
summary(CRT_seen[[3]]<-lm(zero1(DV_irradiation)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_food*zero1(PSIDstrength)*zero1(CRTall)+OutParty_food*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_seen01==0 & CRT_honest==1))) #CRT

summary(CRT_seen[[4]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_seen01==0 & CRT_honest==1))) #CRT
summary(CRT_seen[[5]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+zero1(CRTall)+InParty_farm*zero1(CRTall)+OutParty_farm*zero1(CRTall) +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_seen01==0 & CRT_honest==1))) #CRT
summary(CRT_seen[[6]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+zero1(CRTall)+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*zero1(CRTall)+OutParty_farm*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_farm*zero1(PSIDstrength)*zero1(CRTall)+OutParty_farm*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_seen01==0 & CRT_honest==1))) #CRT


stargazer(CRT_seen[[1]], CRT_seen[[2]], CRT_seen[[3]], title="Study 3 Food Irradiation Experiment: CRT results for those who had never seen CRT", align=TRUE, order=c(1,2,3,4,11,12, 13,14,15,16,17,5,6,7,8,9,10), covariate.labels=c("In-party cue", "Out-party cue", "Partisan Identity Strength (PSID)","Cognitive resource", "In-party * PSID", "Out-party * PSID", "In-party * Cognitive", "Out-party * Cognitive", "PSID * Cognitive", "In-party * PSID * Cognitive", "Out-party * PSID * Cognitive", "Age", "Female", "Race: non-white", "Education: Some college", "Education: College", "Party: Republican", "Constant"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "+p<.1; *p<0.05", column.sep.width = "1pt",
          no.space=TRUE,font.size="tiny" , out = "Study3_CRTnew.tex",dep.var.caption = "Policy support",column.labels = c("Food Irradiation", "Farm"), column.separate = c(3, 1), dep.var.labels.include = F,label="tab:stud3_crtnew", digits=2)


stargazer(CRT_seen[[4]], CRT_seen[[5]], CRT_seen[[6]], title="Study 3 Farm Policy Experiment: CRT results for those who had never seen CRT", align=TRUE, order=c(1,2,3,4,11,12, 13,14,15,16,17,5,6,7,8,9,10), covariate.labels=c("In-party cue", "Out-party cue", "Partisan Identity Strength (PSID)","Cognitive resource", "In-party * PSID", "Out-party * PSID", "In-party * Cognitive", "Out-party * Cognitive", "PSID * Cognitive", "In-party * PSID * Cognitive", "Out-party * PSID * Cognitive", "Age", "Female", "Race: non-white", "Education: Some college", "Education: College", "Party: Republican", "Constant"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "+p<.1; *p<0.05", column.sep.width = "1pt",
          no.space=TRUE,font.size="tiny" , out = "Study3_CRTnewfarm.tex",dep.var.caption = "Policy support",column.labels = c("Food Irradiation", "Farm"), column.separate = c(3, 1), dep.var.labels.include = F,label="tab:stud3_crtnew_farm", digits=2)

#CRT
m0 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_seen01==0 & CRT_honest==1))
summary(m0)
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_seen01==0 & CRT_honest==1))
summary(m1)
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_seen01==0 & CRT_honest==1))
summary(m2)
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("Food Irradiation\n Experiment")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

## CRT at 0 or -1SD
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_seen01==0 & CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_seen01==0 & CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_seen01==0 & CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_farm <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_farm$battery      <- c("Farm Subsidy\n Experiment")
forplot_farm$CRT <- factor(forplot_farm$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_farm)
forpaper$battery <- factor(forpaper$battery,levels = c("Food Irradiation\n Experiment","Farm Subsidy\n Experiment"))
crt3<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+geom_line(aes(linetype=Cue, color=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effect of Party Cues on Policy Support ")+geom_ribbon(aes(ymin=lb,ymax=ub, fill=Cue),alpha=.4)+geom_hline(yintercept = 0,lty="dashed")+scale_fill_manual(values=c("dark green", "red"))+scale_colour_manual(values=c("black", "black")) + theme(strip.text.y = element_text(angle = 360), legend.position="bottom")
ggsave(crt3, file="study3_CRT_seen.pdf",width=8,height=6)




### Appendix C.17: Models without covariates: Food Irradiation Experiment --------------------

#Two-way
results_food<-list()
summary(results_food[[1]]<-lm(zero1(DV_irradiation)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) ,subset(data, CRT_honest==1))) #CRT
summary(results_food[[2]]<-lm(zero1(DV_irradiation)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(NFC)*zero1(PSIDstrength) ,data)) #NFC
summary(results_food[[3]]<-lm(zero1(DV_irradiation)~InParty_food+OutParty_food + zero1(PSIDstrength)+cogresources+InParty_food*cogresources+OutParty_food*cogresources +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + cogresources*zero1(PSIDstrength),data, CRT_honest==1)) #resources

#Three way
summary(results_food[[4]]<-lm(zero1(DV_irradiation)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_food*zero1(PSIDstrength)*zero1(CRTall)+OutParty_food*zero1(PSIDstrength)*zero1(CRTall) ,subset(data, CRT_honest==1))) #CRT
summary(results_food[[5]]<-lm(zero1(DV_irradiation)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_food*zero1(PSIDstrength)*zero1(NFC)+OutParty_food*zero1(PSIDstrength)*zero1(NFC),data)) #NFC
summary(results_food[[6]]<-lm(zero1(DV_irradiation)~InParty_food+OutParty_food+zero1(PSIDstrength)+cogresources+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*cogresources+OutParty_food*cogresources+zero1(PSIDstrength)*cogresources+InParty_food*zero1(PSIDstrength)*cogresources+OutParty_food*zero1(PSIDstrength)*cogresources,subset(data, CRT_honest==1))) #Cog resources

#replace names 2 way model
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "InParty_food:zero1(CRTall)"] <- "InParty:CRT"
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "OutParty_food:zero1(CRTall)"] <- "OutParty:CRT"
names(results_food[[1]]$coefficients)[names(results_food[[1]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"

names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "InParty_food:zero1(NFC)"] <- "InParty:CRT"
names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "OutParty_food:zero1(NFC)"] <- "OutParty:CRT"
names(results_food[[2]]$coefficients)[names(results_food[[2]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"

names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "cogresources"] <- "CRT"
names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "InParty_food:cogresources"] <- "InParty:CRT"
names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "OutParty_food:cogresources"] <- "OutParty:CRT"
names(results_food[[3]]$coefficients)[names(results_food[[3]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"

#replace names 3-way table
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "InParty_food:zero1(CRTall)"] <- "InParty:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "OutParty_food:zero1(CRTall)"] <- "OutParty:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "InParty_food:zero1(PSIDstrength):zero1(CRTall)"] <- "InParty:PIDstrength:CRT"
names(results_food[[4]]$coefficients)[names(results_food[[4]]$coefficients) == "OutParty_food:zero1(PSIDstrength):zero1(CRTall)"] <- "OutParty:PIDstrength:CRT"

names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "InParty_food:zero1(NFC)"] <- "InParty:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "OutParty_food:zero1(NFC)"] <- "OutParty:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "InParty_food:zero1(PSIDstrength):zero1(NFC)"] <- "InParty:PIDstrength:CRT"
names(results_food[[5]]$coefficients)[names(results_food[[5]]$coefficients) == "OutParty_food:zero1(PSIDstrength):zero1(NFC)"] <- "OutParty:PIDstrength:CRT"

names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "cogresources"] <- "CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "InParty_food:cogresources"] <- "InParty:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "OutParty_food:cogresources"] <- "OutParty:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "InParty_food:zero1(PSIDstrength):cogresources"] <- "InParty:PIDstrength:CRT"
names(results_food[[6]]$coefficients)[names(results_food[[6]]$coefficients) == "OutParty_food:zero1(PSIDstrength):cogresources"] <- "OutParty:PIDstrength:CRT"

stargazer(results_food[[1]], results_food[[4]], results_food[[2]], results_food[[5]],results_food[[3]], results_food[[6]], title="Study 3: Food irradiation support, party cues, reflection and social identity strength", align=TRUE, covariate.labels=c("In-party cue", "Out-party cue", "Partisan Identity Strength (PSID)","Cognitive resource", "In-party * PSID", "Out-party * PSID", "In-party * Cognitive", "Out-party * Cognitive", "PSID * Cognitive", "In-party * PSID * Cognitive", "Out-party * PSID * Cognitive", "Constant"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "+p<.1; *p<0.05", column.sep.width = "1pt",
          no.space=TRUE,font.size="tiny" , out = "Study3_summary_cov.tex",dep.var.caption = "Policy support",column.labels = c("CRT", "NFC", "Cog resources"), column.separate = c(2, 2, 2), dep.var.labels.include = F,label="tab:stud3_cov", digits=2)


### Create the figure belonging to Appendix C.1

#CRT
m0 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength ,subset(data, CRT_honest==1))
summary(m0)
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength,subset(data, CRT_honest==1))
summary(m1)
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength,subset(data, CRT_honest==1))
summary(m2)
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

##NFC plots belonging to Figure 
## NFC at 0 or -1SD
m0 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)-sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)-sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength ,data)
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)+sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)+sd(zero1(NFC),na.rm=T),scale=F)*PSIDstrength,data)
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'
forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot_nfc$CRT,levels = c("-1 SD","Mean","+1 SD"))

#Cognitive resources
m0 <- lm(zero1(DV_irradiation)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(zero1(DV_irradiation)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(zero1(DV_irradiation)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'
forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
food_replication<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+geom_line(aes(linetype=Cue, color=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effect of Party Cues on Policy Support ")+geom_ribbon(aes(ymin=lb,ymax=ub, fill=Cue),alpha=.4)+geom_hline(yintercept = 0,lty="dashed")+scale_fill_manual(values=c("dark green", "red"))+scale_colour_manual(values=c("black", "black")) + theme(strip.text.y = element_text(angle = 360), legend.position="bottom")
ggsave(food_replication, file="study3_food_cov.pdf",width=8,height=6)



### Appendix C.17: Models without covariates: Farm Subsidy Experiment --------------------

#Two-way
results_farm<-list()
summary(results_farm[[1]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+zero1(CRTall)+InParty_farm*zero1(CRTall)+OutParty_farm*zero1(CRTall) +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) ,data, CRT_honest==1)) #CRT
summary(results_farm[[2]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+zero1(NFC)+InParty_farm*zero1(NFC)+OutParty_farm*zero1(NFC) +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + zero1(NFC)*zero1(PSIDstrength),data)) #NFC
summary(results_farm[[3]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+cogresources+InParty_farm*cogresources+OutParty_farm*cogresources +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + cogresources*zero1(PSIDstrength) ,data, CRT_honest==1)) #cog resources

#Three way
summary(results_farm[[4]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+zero1(CRTall)+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*zero1(CRTall)+OutParty_farm*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_farm*zero1(PSIDstrength)*zero1(CRTall)+OutParty_farm*zero1(PSIDstrength)*zero1(CRTall) ,data, CRT_honest==1)) #CRT
summary(results_farm[[5]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+zero1(NFC)+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*zero1(NFC)+OutParty_farm*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_farm*zero1(PSIDstrength)*zero1(NFC)+OutParty_farm*zero1(PSIDstrength)*zero1(NFC) ,data)) #NFC
summary(results_farm[[6]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+cogresources+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*cogresources+OutParty_farm*cogresources+zero1(PSIDstrength)*cogresources+InParty_farm*zero1(PSIDstrength)*cogresources+OutParty_farm*zero1(PSIDstrength)*cogresources  ,data, CRT_honest==1)) #cog resources

#replace names 2 way model
names(results_farm[[1]]$coefficients)[names(results_farm[[1]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(results_farm[[1]]$coefficients)[names(results_farm[[1]]$coefficients) == "InParty_farm:zero1(CRTall)"] <- "InParty:CRT"
names(results_farm[[1]]$coefficients)[names(results_farm[[1]]$coefficients) == "OutParty_farm:zero1(CRTall)"] <- "OutParty:CRT"
names(results_farm[[1]]$coefficients)[names(results_farm[[1]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"

names(results_farm[[2]]$coefficients)[names(results_farm[[2]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(results_farm[[2]]$coefficients)[names(results_farm[[2]]$coefficients) == "InParty_farm:zero1(NFC)"] <- "InParty:CRT"
names(results_farm[[2]]$coefficients)[names(results_farm[[2]]$coefficients) == "OutParty_farm:zero1(NFC)"] <- "OutParty:CRT"
names(results_farm[[2]]$coefficients)[names(results_farm[[2]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"

names(results_farm[[3]]$coefficients)[names(results_farm[[3]]$coefficients) == "cogresources"] <- "CRT"
names(results_farm[[3]]$coefficients)[names(results_farm[[3]]$coefficients) == "InParty_farm:cogresources"] <- "InParty:CRT"
names(results_farm[[3]]$coefficients)[names(results_farm[[3]]$coefficients) == "OutParty_farm:cogresources"] <- "OutParty:CRT"
names(results_farm[[3]]$coefficients)[names(results_farm[[3]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"

#replace names 3-way table
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "InParty_farm:zero1(CRTall)"] <- "InParty:CRT"
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "OutParty_farm:zero1(CRTall)"] <- "OutParty:CRT"
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "InParty_farm:zero1(PSIDstrength):zero1(CRTall)"] <- "InParty:PIDstrength:CRT"
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "OutParty_farm:zero1(PSIDstrength):zero1(CRTall)"] <- "OutParty:PIDstrength:CRT"

names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "InParty_farm:zero1(NFC)"] <- "InParty:CRT"
names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "OutParty_farm:zero1(NFC)"] <- "OutParty:CRT"
names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"
names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "InParty_farm:zero1(PSIDstrength):zero1(NFC)"] <- "InParty:PIDstrength:CRT"
names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "OutParty_farm:zero1(PSIDstrength):zero1(NFC)"] <- "OutParty:PIDstrength:CRT"

names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "cogresources"] <- "CRT"
names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "InParty_farm:cogresources"] <- "InParty:CRT"
names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "OutParty_farm:cogresources"] <- "OutParty:CRT"
names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"
names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "InParty_farm:zero1(PSIDstrength):cogresources"] <- "InParty:PIDstrength:CRT"
names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "OutParty_farm:zero1(PSIDstrength):cogresources"] <- "OutParty:PIDstrength:CRT"

stargazer(results_farm[[1]], results_farm[[4]], results_farm[[2]], results_farm[[5]],results_farm[[3]], results_farm[[6]], title="Replication Farm Policy study: party cues, reflection and social identity strength", align=TRUE,covariate.labels=c("In-party cue", "Out-party cue", "Partisan Identity Strength (PSID)","Cognitive resource", "In-party * PSID", "Out-party * PSID", "In-party * Cognitive", "Out-party * Cognitive", "PSID * Cognitive", "In-party * PSID * Cognitive", "Out-party * PSID * Cognitive", "Constant"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "+p<.1; *p<0.05", column.sep.width = "1pt",
          no.space=TRUE,font.size="tiny" , out = "Study3_summary_farm_cov.tex",dep.var.caption = "Policy support",column.labels = c("CRT", "NFC", "Cog resoucres"), column.separate = c(2, 2, 2), dep.var.labels.include = F,label="tab:stud3_farmcov", digits=2)


####Figure for Farm Policy 
## CRT at 0 or -1SD
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'
summary(m0)
## CRT at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'
summary(m2)
forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

##NfC plots belonging to Figure for Farm Policy
## NFC at 0 or -1SD
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength,data)
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## NFC at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength,data)
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## NFC at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength,data)
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

## Cog resources at -1
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
farm_replication<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+geom_line(aes(linetype=Cue, color=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effect of Party Cues on Policy Support ")+geom_ribbon(aes(ymin=lb,ymax=ub, fill=Cue),alpha=.4)+geom_hline(yintercept = 0,lty="dashed")+scale_fill_manual(values=c("dark green", "red"))+scale_colour_manual(values=c("black", "black")) + theme(strip.text.y = element_text(angle = 360), legend.position="bottom") 
ggsave(farm_replication, file="study3_farm_cov.pdf",width=8,height=6)



### Appendix C.18: Spillover effects------------------


#Two-way
results_farm<-list()
summary(results_farm[[1]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+zero1(CRTall)+InParty_farm*zero1(CRTall)+OutParty_farm*zero1(CRTall) +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy + InParty_food + OutParty_food ,data, CRT_honest==1)) #CRT
summary(results_farm[[2]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+zero1(NFC)+InParty_farm*zero1(NFC)+OutParty_farm*zero1(NFC) +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + zero1(NFC)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy + InParty_food + OutParty_food,data)) #NFC
summary(results_farm[[3]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+cogresources+InParty_farm*cogresources+OutParty_farm*cogresources +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + cogresources*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy + InParty_food + OutParty_food ,data, CRT_honest==1)) #cog resources

#Three way
summary(results_farm[[4]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+zero1(CRTall)+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*zero1(CRTall)+OutParty_farm*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_farm*zero1(PSIDstrength)*zero1(CRTall)+OutParty_farm*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy  + InParty_food+ OutParty_food ,data, CRT_honest==1)) #CRT
summary(results_farm[[5]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+zero1(NFC)+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*zero1(NFC)+OutParty_farm*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_farm*zero1(PSIDstrength)*zero1(NFC)+OutParty_farm*zero1(PSIDstrength)*zero1(NFC)+ age+female+ non_white +as.factor(edu)+Republican_dummy   + InParty_food+ OutParty_food,data)) #NFC
summary(results_farm[[6]]<-lm(zero1(Farm_dv_support_rec)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+cogresources+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*cogresources+OutParty_farm*cogresources+zero1(PSIDstrength)*cogresources+InParty_farm*zero1(PSIDstrength)*cogresources+OutParty_farm*zero1(PSIDstrength)*cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy  + InParty_food + OutParty_food,data, CRT_honest==1)) #cog resources

#replace names 2 way model
names(results_farm[[1]]$coefficients)[names(results_farm[[1]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(results_farm[[1]]$coefficients)[names(results_farm[[1]]$coefficients) == "InParty_farm:zero1(CRTall)"] <- "InParty:CRT"
names(results_farm[[1]]$coefficients)[names(results_farm[[1]]$coefficients) == "OutParty_farm:zero1(CRTall)"] <- "OutParty:CRT"
names(results_farm[[1]]$coefficients)[names(results_farm[[1]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"

names(results_farm[[2]]$coefficients)[names(results_farm[[2]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(results_farm[[2]]$coefficients)[names(results_farm[[2]]$coefficients) == "InParty_farm:zero1(NFC)"] <- "InParty:CRT"
names(results_farm[[2]]$coefficients)[names(results_farm[[2]]$coefficients) == "OutParty_farm:zero1(NFC)"] <- "OutParty:CRT"
names(results_farm[[2]]$coefficients)[names(results_farm[[2]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"

names(results_farm[[3]]$coefficients)[names(results_farm[[3]]$coefficients) == "cogresources"] <- "CRT"
names(results_farm[[3]]$coefficients)[names(results_farm[[3]]$coefficients) == "InParty_farm:cogresources"] <- "InParty:CRT"
names(results_farm[[3]]$coefficients)[names(results_farm[[3]]$coefficients) == "OutParty_farm:cogresources"] <- "OutParty:CRT"
names(results_farm[[3]]$coefficients)[names(results_farm[[3]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"

#replace names 3-way table
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "zero1(CRTall)"] <- "CRT"
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "InParty_farm:zero1(CRTall)"] <- "InParty:CRT"
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "OutParty_farm:zero1(CRTall)"] <- "OutParty:CRT"
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "zero1(PSIDstrength):zero1(CRTall)"] <- "PIDstrength:CRT"
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "InParty_farm:zero1(PSIDstrength):zero1(CRTall)"] <- "InParty:PIDstrength:CRT"
names(results_farm[[4]]$coefficients)[names(results_farm[[4]]$coefficients) == "OutParty_farm:zero1(PSIDstrength):zero1(CRTall)"] <- "OutParty:PIDstrength:CRT"

names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "zero1(NFC)"] <- "CRT"
names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "InParty_farm:zero1(NFC)"] <- "InParty:CRT"
names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "OutParty_farm:zero1(NFC)"] <- "OutParty:CRT"
names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "zero1(PSIDstrength):zero1(NFC)"] <- "PIDstrength:CRT"
names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "InParty_farm:zero1(PSIDstrength):zero1(NFC)"] <- "InParty:PIDstrength:CRT"
names(results_farm[[5]]$coefficients)[names(results_farm[[5]]$coefficients) == "OutParty_farm:zero1(PSIDstrength):zero1(NFC)"] <- "OutParty:PIDstrength:CRT"

names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "cogresources"] <- "CRT"
names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "InParty_farm:cogresources"] <- "InParty:CRT"
names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "OutParty_farm:cogresources"] <- "OutParty:CRT"
names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "zero1(PSIDstrength):cogresources"] <- "PIDstrength:CRT"
names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "InParty_farm:zero1(PSIDstrength):cogresources"] <- "InParty:PIDstrength:CRT"
names(results_farm[[6]]$coefficients)[names(results_farm[[6]]$coefficients) == "OutParty_farm:zero1(PSIDstrength):cogresources"] <- "OutParty:PIDstrength:CRT"

stargazer(results_farm[[1]], results_farm[[4]], results_farm[[2]], results_farm[[5]],results_farm[[3]], results_farm[[6]], title="Replication Farm Policy study: party cues, reflection and social identity strength", order=c(1,2,3,4,13,14, 15,16,17,18,19,5,6,7,8,9,10, 11, 12), align=TRUE, covariate.labels=c("In-party cue", "Out-party cue", "Partisan Identity Strength (PSID)","Cognitive resource", "In-party * PSID", "Out-party * PSID", "In-party * Cognitive", "Out-party * Cognitive", "PSID * Cognitive", "In-party * PSID * Cognitive", "Out-party * PSID * Cognitive", "Age", "Female", "Race: non-white", "Education: Some college", "Education: College", "Party: Republican", "Food Irradiation: In-party cue", "Food Irradiation: Out-party cue", "Constant"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "+p<.1; *p<0.05", column.sep.width = "1pt",
          no.space=TRUE,font.size="tiny" , out = "Study3_summary_farm_spillover.tex",dep.var.caption = "Policy support",column.labels = c("CRT", "NFC", "Cog resoucres"), column.separate = c(2, 2, 2), dep.var.labels.include = F,label="tab:stud3_farm_spill", digits=2)


####Figure for Farm Policy 
## CRT at 0 or -1SD
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy+ InParty_food + OutParty_food,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'
summary(m0)
## CRT at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy+ InParty_food + OutParty_food,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy+ InParty_food + OutParty_food,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'
summary(m2)
forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

##NfC plots belonging to Figure for Farm Policy
## NFC at 0 or -1SD
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy+ InParty_food + OutParty_food,data)
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## NFC at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy+ InParty_food + OutParty_food,data)
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## NFC at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength+ OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy+ InParty_food + OutParty_food,data)
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

## Cog resources at -1
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy+ InParty_food + OutParty_food,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='PSIDstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='PSIDstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy+ InParty_food + OutParty_food,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='PSIDstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='PSIDstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*PSIDstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy+ InParty_food + OutParty_food,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='PSIDstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='PSIDstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
farm_replication<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+geom_line(aes(linetype=Cue, color=Cue))+facet_grid(battery~CRT)+xlab("Partisan Social Identity Strength")+theme_bw()+ylab("Marginal effect of Party Cues on Policy Support ")+geom_ribbon(aes(ymin=lb,ymax=ub, fill=Cue),alpha=.4)+geom_hline(yintercept = 0,lty="dashed")+scale_fill_manual(values=c("dark green", "red"))+scale_colour_manual(values=c("black", "black")) + theme(strip.text.y = element_text(angle = 360), legend.position="bottom") 
ggsave(farm_replication, file="study3_farm_spillover.pdf",width=8,height=6)


### Appendix F: Traditional party identity strength measurure --- Food Irradiation Experiment------------------

cor.test(data$PSIDstrength, data$pidstrength)
#Food Irradiation

#CRT
m0 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*pidstrength+OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='pidstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='pidstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*pidstrength+OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='pidstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='pidstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*pidstrength+ OutParty_food*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='pidstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='pidstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

##NFC plots belonging to Figure 
## NFC at 0 or -1SD
m0 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)-sd(zero1(NFC),na.rm=T),scale=F)*pidstrength+OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)-sd(zero1(NFC),na.rm=T),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='pidstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='pidstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## CRT at mean
m1 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*pidstrength+OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='pidstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='pidstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(DV_irradiation)~InParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)+sd(zero1(NFC),na.rm=T),scale=F)*pidstrength+ OutParty_food*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T)+sd(zero1(NFC),na.rm=T),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='pidstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='pidstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot_nfc$CRT,levels = c("-1 SD","Mean","+1 SD"))

#Cognitive resources
m0 <- lm(zero1(DV_irradiation)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*pidstrength+ OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_food",var2='pidstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_food",var2='pidstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(zero1(DV_irradiation)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*pidstrength+OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_food",var2='pidstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_food",var2='pidstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(zero1(DV_irradiation)~InParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*pidstrength+ OutParty_food*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_food",var2='pidstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_food",var2='pidstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
forpaper$fake <- factor(forpaper$fake,levels = c("0","0.5","1"))

food_pidstrength<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+facet_grid(battery~CRT)+xlab("Party Identity Strength")+theme_bw()+ylab("Marginal effect of In-party cue and Out-party cue on Policy Support ")+geom_pointrange(aes(ymin=lb,ymax=ub, fill=Cue),alpha=1)+geom_hline(yintercept = 0,lty="dashed")+scale_colour_manual(values = c("dark green", "red"))+ theme(strip.text.y = element_text(angle = 360), legend.position="bottom") + scale_x_discrete(labels = c("0" = "Not","0.5" = "Weak", "1"="Strong"))
ggsave(food_pidstrength, file="study4_food_pidstrength.pdf",width=8,height=6)


### Appendix F: Traditional party identity strength measurure --- Farm Subsidy Experiment------------------

## CRT at 0 or -1SD
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*pidstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))-sd(zero1(CRTall)),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='pidstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='pidstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'
summary(m2)
## CRT at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*pidstrength+OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall),na.rm=T),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='pidstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='pidstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## CRT at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*pidstrength+ OutParty_farm*scale(zero1(CRTall),center=mean(zero1(CRTall))+sd(zero1(CRTall)),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='pidstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='pidstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot$battery      <- c("CRT")
forplot$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

##NfC plots belonging to Figure for Farm Policy
## NFC at 0 or -1SD
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*pidstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))-sd(zero1(NFC)),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='pidstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='pidstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## NFC at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*pidstrength+OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC),na.rm=T),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='pidstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='pidstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## NFC at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*pidstrength+ OutParty_farm*scale(zero1(NFC),center=mean(zero1(NFC))+sd(zero1(NFC)),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='pidstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='pidstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_nfc <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_nfc$battery      <- c("NFC")
forplot_nfc$CRT <- factor(forplot$CRT,levels = c("-1 SD","Mean","+1 SD"))

## Cog resources at -1
m0 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*pidstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)-sd(cogresources,na.rm=T),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_0_out <- interplot(m0,var1 = "OutParty_farm",var2='pidstrength')
m_0_out$data$CRT='-1 SD'
m_0_out$data$Cue='Out'
m_0_in <- interplot(m0,var1 = "InParty_farm",var2='pidstrength')
m_0_in$data$CRT='-1 SD'
m_0_in$data$Cue='In'

## Cog resoucres at mean
m1 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*pidstrength+OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T),scale=F)*pidstrength+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))
m_1_out <- interplot(m1,var1 = "OutParty_farm",var2='pidstrength')
m_1_out$data$CRT='Mean'
m_1_out$data$Cue='Out'
m_1_in <- interplot(m1,var1 = "InParty_farm",var2='pidstrength')
m_1_in$data$CRT='Mean'
m_1_in$data$Cue='In'

## Cog resources at +1
m2 <- lm(zero1(Farm_dv_support_rec)~InParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*pidstrength+ OutParty_farm*scale(cogresources,center=mean(cogresources,na.rm=T)+sd(cogresources,na.rm=T),scale=F)*pidstrength,subset(data, CRT_honest==1))
m_2_out <- interplot(m2,var1 = "OutParty_farm",var2='pidstrength')
m_2_out$data$CRT='+1 SD'
m_2_out$data$Cue='Out'
m_2_in <- interplot(m2,var1 = "InParty_farm",var2='pidstrength')
m_2_in$data$CRT='+1 SD'
m_2_in$data$Cue='In'

forplot_cog <- rbind(m_0_in$data, m_0_out$data,m_1_in$data,m_1_out$data,m_2_in$data,m_2_out$data)
forplot_cog$battery      <- c("Cognitive\n resources")
forplot_cog$CRT <- factor(forplot_cog$CRT,levels = c("-1 SD","Mean","+1 SD"))

##Combine plots
forpaper <- rbind(forplot, forplot_nfc, forplot_cog)
forpaper$battery <- factor(forpaper$battery,levels = c("CRT","NFC","Cognitive\n resources"))
forpaper$fake <- factor(forpaper$fake,levels = c("0","0.5","1"))

farm_pidstrength<-ggplot(forpaper,aes(x=fake,y=coef1, colour=Cue))+facet_grid(battery~CRT)+xlab("Party Identity Strength")+theme_bw()+ylab("Marginal effect of In-party cue and Out-party cue on Policy Support ")+geom_pointrange(aes(ymin=lb,ymax=ub, fill=Cue),alpha=1)+geom_hline(yintercept = 0,lty="dashed")+scale_colour_manual(values = c("dark green", "red"))+ theme(strip.text.y = element_text(angle = 360), legend.position="bottom") + scale_x_discrete(labels = c("0" = "Not","0.5" = "Weak", "1"="Strong"))
ggsave(farm_pidstrength, file="study4_farm_pidstrength.pdf",width=8,height=6)

### Appendix G: Partisanship and policy preferences in the control conditions ----------------
data$partisanship1_6<-car::recode(data$partisanship, "5=4; 6=5; 7=6")

pid_control<-list()
summary(pid_control[[1]]<-lm(zero1(DV_irradiation)~partisanship1_6,subset(data, treatment==1)))
summary(pid_control[[2]]<-lm(zero1(DV_irradiation)~Republican_dummy,subset(data, treatment==1)))
summary(pid_control[[3]]<-lm(zero1(Farm_dv_support_rec)~partisanship1_6,subset(data, treatment==1)))
summary(pid_control[[4]]<-lm(zero1(Farm_dv_support_rec)~Republican_dummy,subset(data, treatment==1)))
summary(pid_control[[3]])
stargazer(pid_control[[1]], pid_control[[2]], pid_control[[3]], pid_control[[4]], title="Study 3 Partisanship and policy preferences in the Control Conditions of Food and Farm Policy Experiments", align=TRUE, covariate.labels=c("Partisanship (6-point)", "Republican (Ref. Democrat)"),
          omit.stat=c("LL","ser","f", "adj.rsq"), 
          notes.append = FALSE, 
          star.cutoffs=c(0.1, 0.05), star.char = c("+", "*"),
          notes = "+p<.1; *p<0.05", column.sep.width = "1pt",
          no.space=TRUE,font.size="small" , out = "Study4_control.tex",dep.var.caption = "Policy support",column.labels = c("Food Irradiation", "Farm Subsidy"), column.separate = c(2, 2), dep.var.labels.include = F,label="tab:control4", digits=2)



### Not presented in Online Appendix: Food Irradiation Quiz results using negative binomial regression models ----------------

food_quiz_nbreg<-list()
summary(food_quiz_nbreg[[1]]<-glm.nb(zero1(Quiz_correct)~InParty_food + OutParty_food + zero1(PSIDstrength) + zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) # Strong identifiers read less. High CRT read more
summary(food_quiz_nbreg[[2]]<-glm.nb(zero1(Quiz_correct)~InParty_food + OutParty_food + zero1(PSIDstrength) + zero1(NFC)+ age+female+ non_white +as.factor(edu)+Republican_dummy,data)) #NFC Strong identifiers read less. High NfC read more
summary(food_quiz_nbreg[[3]]<-glm.nb(zero1(Quiz_correct)~InParty_food + OutParty_food + zero1(PSIDstrength) + cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #Strong identifiers read less. High Resources read more

#twoway
summary(food_quiz_nbreg[[4]]<-glm.nb(zero1(Quiz_correct)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(food_quiz_nbreg[[5]]<-glm.nb(zero1(Quiz_correct)~InParty_food+OutParty_food + zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC) +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + zero1(NFC)*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,data)) #NFC
summary(food_quiz_nbreg[[6]]<-glm.nb(zero1(Quiz_correct)~InParty_food+OutParty_food + zero1(PSIDstrength)+cogresources+InParty_food*cogresources+OutParty_food*cogresources +InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength) + cogresources*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #resources

#Three way
summary(food_quiz_nbreg[[7]]<-glm.nb(zero1(Quiz_correct)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_food*zero1(PSIDstrength)*zero1(CRTall)+OutParty_food*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(food_quiz_nbreg[[8]]<-glm.nb(zero1(Quiz_correct)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_food*zero1(PSIDstrength)*zero1(NFC)+OutParty_food*zero1(PSIDstrength)*zero1(NFC) + age+female+ non_white +as.factor(edu)+Republican_dummy,data)) #NFC
summary(food_quiz_nbreg[[9]]<-glm.nb(zero1(Quiz_correct)~InParty_food+OutParty_food+zero1(PSIDstrength)+cogresources+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*cogresources+OutParty_food*cogresources+zero1(PSIDstrength)*cogresources+InParty_food*zero1(PSIDstrength)*cogresources+OutParty_food*zero1(PSIDstrength)*cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #Cog resources

### Not presented in Online Appendix: Farm Policy Quiz results using negative binomial regression models ----------------
#main effects
farm_quiz<-list()
summary(farm_quiz[[1]]<-glm.nb(zero1(Farm_Quiz_correct)~InParty_farm + OutParty_farm + zero1(PSIDstrength) + zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #CRT
summary(farm_quiz[[2]]<-glm.nb(zero1(Farm_Quiz_correct)~InParty_farm + OutParty_farm + zero1(PSIDstrength) + zero1(NFC)+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data))) #NFC
summary(farm_quiz[[3]]<-glm.nb(zero1(Farm_Quiz_correct)~InParty_farm + OutParty_farm + zero1(PSIDstrength) +cogresources + age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #NFC

#Twoway
summary(farm_quiz[[4]]<-glm.nb(zero1(Farm_Quiz_correct)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+zero1(CRTall)+InParty_farm*zero1(CRTall)+OutParty_farm*zero1(CRTall) +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + zero1(CRTall)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,data, CRT_honest==1)) #CRT
summary(farm_quiz[[5]]<-glm.nb(zero1(Farm_Quiz_correct)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+zero1(NFC)+InParty_farm*zero1(NFC)+OutParty_farm*zero1(NFC) +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + zero1(NFC)*zero1(PSIDstrength) + age+female+ non_white +as.factor(edu)+Republican_dummy ,data)) #NFC
summary(farm_quiz[[6]]<-glm.nb(zero1(Farm_Quiz_correct)~InParty_farm+OutParty_farm + zero1(PSIDstrength)+cogresources+InParty_farm*cogresources+OutParty_farm*cogresources +InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength) + cogresources*zero1(PSIDstrength)+ age+female+ non_white +as.factor(edu)+Republican_dummy  ,data, CRT_honest==1)) #cog resources

#Three way
summary(farm_quiz[[7]]<-glm.nb(log1p(Farm_time_Page_Submit)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+zero1(CRTall)+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*zero1(CRTall)+OutParty_farm*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_farm*zero1(PSIDstrength)*zero1(CRTall)+OutParty_farm*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(farm_quiz[[8]]<-glm.nb(log1p(Farm_time_Page_Submit)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+zero1(NFC)+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*zero1(NFC)+OutParty_farm*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_farm*zero1(PSIDstrength)*zero1(NFC)+OutParty_farm*zero1(PSIDstrength)*zero1(NFC) + age+female+ non_white +as.factor(edu)+Republican_dummy,data)) #NFC
summary(farm_quiz[[9]]<-glm.nb(log1p(Farm_time_Page_Submit)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+cogresources+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*cogresources+OutParty_farm*cogresources+zero1(PSIDstrength)*cogresources+InParty_farm*zero1(PSIDstrength)*cogresources+OutParty_farm*zero1(PSIDstrength)*cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #Cog resources


### Not presented in Online Appendix: Ranked reading time ----------------------
data$food_time_ranked<-rank(data$Food_time_Page_Submit,ties.method = "average")
data$farm_time_ranked<-rank(data$Farm_time_Page_Submit,ties.method = "average")

#Ranked reading time Food Irradiation
ranked_time<-list()
summary(ranked_time[[1]]<-lm(zero1(food_time_ranked)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(CRTall)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(CRTall)+OutParty_food*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_food*zero1(PSIDstrength)*zero1(CRTall)+OutParty_food*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(ranked_time[[2]]<-lm(zero1(food_time_ranked)~InParty_food+OutParty_food+zero1(PSIDstrength)+zero1(NFC)+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*zero1(NFC)+OutParty_food*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_food*zero1(PSIDstrength)*zero1(NFC)+OutParty_food*zero1(PSIDstrength)*zero1(NFC) + age+female+ non_white +as.factor(edu)+Republican_dummy,data)) #NFC
summary(ranked_time[[3]]<-lm(zero1(food_time_ranked)~InParty_food+OutParty_food+zero1(PSIDstrength)+cogresources+InParty_food*zero1(PSIDstrength)+OutParty_food*zero1(PSIDstrength)+InParty_food*cogresources+OutParty_food*cogresources+zero1(PSIDstrength)*cogresources+InParty_food*zero1(PSIDstrength)*cogresources+OutParty_food*zero1(PSIDstrength)*cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #Cog resources

#Ranked reading time Farm Subsidy 

#Three way
summary(ranked_time[[4]]<-lm(zero1(farm_time_ranked)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+zero1(CRTall)+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*zero1(CRTall)+OutParty_farm*zero1(CRTall)+zero1(PSIDstrength)*zero1(CRTall)+InParty_farm*zero1(PSIDstrength)*zero1(CRTall)+OutParty_farm*zero1(PSIDstrength)*zero1(CRTall)+ age+female+ non_white +as.factor(edu)+Republican_dummy ,subset(data, CRT_honest==1))) #CRT
summary(ranked_time[[5]]<-lm(zero1(farm_time_ranked)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+zero1(NFC)+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*zero1(NFC)+OutParty_farm*zero1(NFC)+zero1(PSIDstrength)*zero1(NFC)+InParty_farm*zero1(PSIDstrength)*zero1(NFC)+OutParty_farm*zero1(PSIDstrength)*zero1(NFC) + age+female+ non_white +as.factor(edu)+Republican_dummy,data)) #NFC
summary(ranked_time[[6]]<-lm(zero1(farm_time_ranked)~InParty_farm+OutParty_farm+zero1(PSIDstrength)+cogresources+InParty_farm*zero1(PSIDstrength)+OutParty_farm*zero1(PSIDstrength)+InParty_farm*cogresources+OutParty_farm*cogresources+zero1(PSIDstrength)*cogresources+InParty_farm*zero1(PSIDstrength)*cogresources+OutParty_farm*zero1(PSIDstrength)*cogresources+ age+female+ non_white +as.factor(edu)+Republican_dummy,subset(data, CRT_honest==1))) #Cog resources

